Re: static function ? how ?



Arjen Markus wrote:
> 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):

Perhaps "the GNU compiler" should be replaced with "a GNU compiler",
since gfortran exists :).

> 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.

Is this part of Fortran 2003 or is it an extension specific to g95?

.