Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Avoiding Global Variables and Subroutines

Status
Not open for further replies.

TheoMoore

Programmer
Feb 11, 2008
5
GB
I'm programming this in Fortran 90.

The overall program follows this format:

Code:
PROGRAM TEST

Declare variables

X = 2

CALL WALMART(FUNC, ...other stuff...)

END TEST

SUBROUTINE FUNC(MONEY, Y)
MONEY = X*Y
END

The problem is simple. I ask for some input array (X), then call a routine called WALMART. The routine makes use of a subroutine (FUNC). The problem arises because the output (MONEY) of FUNC makes use of the input of my main program. However, I cannot alter the input of WALMART. Without using global (COMMON) variables, how do I 'pass' X into the subroutine?

To be more specific, WALMART is a canned routine (NAG Fortran). It's inputs and outputs are fixed, so I can't simply pass X into WALMART, then pass it again into FUNC!

Help!
 
You could try module level variables. Declare func in a module and see if it will go through.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top