Interface confusion

From: Kevin (kevin_fitch_at_yahoo.com)
Date: 06/14/04


Date: 14 Jun 2004 13:15:38 -0700

My basic question: Is this standards compliant (intel-ifort8-8.0-40 on
linux compiles it fine,but DVF6.6c on win2k does not):
!! BEGIN CODE
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!file: foo.f90
module foo
  implicit none
  public
  interface
    elemental function bar(a,b) result (c)
      integer, intent(in) :: a
      real, intent(in) :: b
      real :: c
    end function bar
  end interface
end module foo
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!file: bar.f90
elemental function bar(a,b) result(c)
  use foo
  integer, intent(in) :: a
  real, intent(in) :: b
  real :: c

  c=a+b
end function bar
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
! file: biz.f90
program biz
use foo
implicit none
integer :: a(100)=(/1:100/)
real :: b(100)
real :: c(100)
b=2.0
c=bar(a,b)
 
write(*,*) c
end program biz
!! END CODE

My understanding is that there are only 2 standards compliant
solutions to this:
1) Put bar in module foo via CONTAINS
  This can lead to VERY large source files and extremely long compile
times if module foo contains a few large functions. IMNSHO large
source files and long compile time reduce my productivity.
2) change the 'use foo' line in bar.f90 to 'use foo, only except =>
bar'
  This solves the problems of option 1, but gets rid of much of the
type saftey that modules and interfaces provide.

PS: My background is in C/C++, and I only recently started working
with F95. When I saw modules/interfaces my first thought was that this
was simply a way of provided precompiled header files in the standard
language.



Relevant Pages

  • Re: Interface confusion
    ... > 1) Put bar in module foo via CONTAINS ... > times if module foo contains a few large functions. ... > source files and long compile time reduce my productivity. ...
    (comp.lang.fortran)
  • Re: using a module
    ... Compilers normally let you compile 2 or more files together: ... appended (/MOD_PATH is a compiler command line option). ... Zero or more OBJ files will also be associated with a module. ... END MODULE foo ...
    (comp.lang.fortran)
  • Re: using a module
    ... Compilers normally let you compile 2 or more files together: ... The Fortran 95 standard offers the INCLUDE line, ... END MODULE foo ... PRINT *, fooint ...
    (comp.lang.fortran)