Re: static function ? how ?
- From: Ian Bush <I.J.Bush@xxxxxxxxxxxxxxx>
- Date: Thu, 26 May 2005 08:18:09 +0000
Hi,
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.
>
>
You can't in F77, so why not upgrade to F90 ? Your URL
suggests that you can get a copy of the Intel compiler for free.
You can't do exactly the same in F90, as there is no such thing as file
scope, but you can do something very similar with modules:
Module baz
Implicit None
Public :: bar ! The outside world can see bar
Private ! By default nothing can be seen in the module
! unless declared public
Contains
Subroutine foo( ... ) ! Private, so can only be seen by routines in
! the module
....
End Subroutine foo
Subroutine bar( ... ) ! Public, so can be seen outside the module
....
End Subroutine bar
End Module baz
Modules provide mechanisms that are much more powerful than the simple
file scope provided by C, so I would strongly suggest you look into them,
Hope this helps,
Ian
.
- Follow-Ups:
- Re: static function ? how ?
- From: bv
- Re: static function ? how ?
- From: KC
- Re: static function ? how ?
- References:
- static function ? how ?
- From: KC
- static function ? how ?
- Prev by Date: Re: My philosophy
- Next by Date: Running a fortran programm under Windows XP
- Previous by thread: Re: static function ? how ?
- Next by thread: Re: static function ? how ?
- Index(es):
Relevant Pages
|