Fortran [Fortran] subroutines within the same module

  • Thread starter Thread starter mopen
  • Start date Start date
  • Tags Tags
    Fortran module
Click For Summary
In Fortran 90, variables defined within a subroutine are not automatically available to other subroutines, even if they are within the same module. Each subroutine has its own scope, meaning that variables must be explicitly passed through the argument list to be accessible in the calling subroutine. In the provided example, the variable "F" calculated in subroutine "m" will not be available to subroutine "h" unless it is included in the argument list of "m". Understanding variable scope is crucial for effective programming in Fortran 90.
mopen
Messages
2
Reaction score
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
Do you know what is a scope of the variable? (Google if not)
 
Borek said:
Do you know what is a scope of the variable? (Google if not)

Be Nice to people!
 
Learn If you want to write code for Python Machine learning, AI Statistics/data analysis Scientific research Web application servers Some microcontrollers JavaScript/Node JS/TypeScript Web sites Web application servers C# Games (Unity) Consumer applications (Windows) Business applications C++ Games (Unreal Engine) Operating systems, device drivers Microcontrollers/embedded systems Consumer applications (Linux) Some more tips: Do not learn C++ (or any other dialect of C) as a...

Similar threads

  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 59 ·
2
Replies
59
Views
11K
  • · Replies 14 ·
Replies
14
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K
  • · Replies 8 ·
Replies
8
Views
4K
  • · Replies 14 ·
Replies
14
Views
4K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 11 ·
Replies
11
Views
2K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 5 ·
Replies
5
Views
4K