[Fortran] subroutines within the same module

In summary, the conversation is about a Fortran 90 program with multiple subroutines within the same module. The question is whether the variables of a called subroutine are available to the calling subroutine without being declared in the argument list. An example is given with subroutine "h" calling subroutine "m" and the variable "F" being calculated in "m". The question is whether "F" will be available to "h" without being declared. The conversation also mentions the concept of variable scope and encourages kindness towards others.
  • #1
mopen
2
0
Hi all,

I am working on a Fortran 90 program that has many subroutines within the same module. The question is "are all the variables of a called subroutine are available to the calling subroutine without declaring them in the argument list of the called surboutine"? even though they are within the same module.

for example
****************************************
Module x

Subroutine h
*
*
Call subroutine m (m1,m2,m3)
*
end subroutine h

Subroutine m (m1,m2,m3)
*
*
*
F=*******
end subroutine m

end module x
************************************

so will "F" calculated in subroutine :m" will be available to subroutine "h" without declaring it in the argument list of subroutine "m"?

thanks
 
Technology news on Phys.org
  • #2
Do you know what is a scope of the variable? (Google if not)
 
  • #3
Borek said:
Do you know what is a scope of the variable? (Google if not)

Be Nice to people!
 

FAQ: [Fortran] subroutines within the same module

What are Fortran subroutines within the same module?

Fortran subroutines within the same module refer to subroutines that are declared and defined within the same module. This allows for easier organization and access to the subroutines within a program.

How are subroutines declared within a Fortran module?

In Fortran, subroutines are declared within a module using the "subroutine" keyword, followed by the name of the subroutine and its parameters. The subroutine body is then defined using the "end subroutine" statement.

Can multiple subroutines be defined within the same module in Fortran?

Yes, multiple subroutines can be defined within the same module in Fortran. This can be useful for grouping related subroutines together and improving code organization.

How are subroutines within the same module accessed in a Fortran program?

To access a subroutine within a Fortran module, the "use" statement is used to bring in the module into the program. This allows for the subroutines within the module to be called by their names within the program.

Can subroutines within the same module be called recursively in Fortran?

Yes, subroutines within the same module can be called recursively in Fortran. However, it is important to ensure that the recursive calls do not result in an infinite loop.

Similar threads

Replies
59
Views
10K
Replies
14
Views
2K
Replies
3
Views
2K
Replies
8
Views
4K
Replies
14
Views
4K
Replies
11
Views
1K
Replies
4
Views
2K
Replies
5
Views
3K
Back
Top