[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!
 

Related to [Fortran] subroutines within the same module

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

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

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

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

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

  • Programming and Computer Science
Replies
8
Views
1K
  • Programming and Computer Science
Replies
3
Views
2K
  • Programming and Computer Science
2
Replies
59
Views
9K
  • Programming and Computer Science
Replies
8
Views
3K
  • Programming and Computer Science
Replies
4
Views
1K
  • Programming and Computer Science
Replies
11
Views
1K
  • Programming and Computer Science
Replies
14
Views
4K
  • Programming and Computer Science
Replies
12
Views
3K
  • Programming and Computer Science
Replies
2
Views
3K
  • Programming and Computer Science
Replies
20
Views
2K
Back
Top