Re: static function ? how ?



KC wrote:
>
> Hi,
>
> In C language, we can use:
>
> /* foo.c */
> static void foo(void)
> {
> ...
> }
>
> to define a static function "foo" which is
> local function of file "foo.c".
>
> Can I do the same thing in Fortran ? How ?
> I'm using g77. Thanks.
>
> Best Regards
> KC
> kccheng@xxxxxxxxxxxxxxxxx

You can do this using g95 (that is the GNU
compiler for Fortran 90/95):

Via the contains statement you can introduce new subroutines and
functions
that can only be accessed by each other and the containing routine:

subroutine suba( ... )
....
call subb( ... )
.....
contains
subroutine subb( ... )
write(*,*) 'In subb!'
end subroutine subb

subroutine subc( ... )
...
end subroutine subc

end subroutine suba

(The same for main programs). Modules are even more useful, because
more general.

Regards,

Arjen
.