Re: static function ? how ?
- From: Arjen Markus <arjen.markus@xxxxxxxxxx>
- Date: Thu, 26 May 2005 09:24:52 +0200
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
.
- Follow-Ups:
- Re: static function ? how ?
- From: beliavsky
- Re: static function ? how ?
- References:
- static function ? how ?
- From: KC
- static function ? how ?
- Prev by Date: static function ? how ?
- Next by Date: RE: Running a fortran programm under Windows XP
- Previous by thread: static function ? how ?
- Next by thread: Re: static function ? how ?
- Index(es):