October 20th, 2013, 07:07 AM
Fortran 90 problems of transmission of values to subroutines and functions
Hi everyone, I hope everyone's doing good. I presently have a project at work and I'm having a hard time dealing with some programming techniques.
To summarize my project, I have to modify some codes on Fortran so that it can be adapted to be used on a simulation software called PRO/II. All the functions and subroutines have already been written.
However, to make the codes compatible with PRO/II, I have to change the way of assigning some input data (input by the user himself) on Fortran. In fact, before, the user entered the data on a text file which was then read by a fortran subroutine.
However, now, the data is input in the simulation software directly. I managed to write a code to record all the input data in a subroutine. But when the simulation is ran on PRO/II, it only attributes the input data to the "MAIN SUBROUTINE". The values are not accessible to any functions or subroutines outside the main subroutine. In fact, PRO/II gives the values to the arguments of my main subroutine only.
As from there, when a function is called from the main subroutine, there's no problem. It's the function that calls other functions or subroutines that are the issues. I'll try to make myself as clear as possible. So let's say I have a subroutine X and many functions and subroutines as follows:
Uses Functions B and C
Uses Function D and E
Uses functions D and E
So, the problem is that the values I calculated in my main subroutine or the values I input in PRO/II which are transmitted to the Fortran program are not accessible to functions D and E. So, I tried copying all the values needed to a text file from the main subroutine and reading all the values each time by the different functions and subroutines. But it's taking forever for the simulation to run by PRO/II. I have like 80 functions and 20 subroutines, and each time they are called, they open the text file to read the values.
Is there a way for me to have the values read by all functions and subroutines without having to read from the text file? In other words, is there a way to make all the variables I've calculated in my main subroutine to every function and subroutine in my program?
I'm really having a hard time figuring that out.
If you guys don't understand the problem or have any questions, please let me know.
Thanks in advance for your help guys.
December 12th, 2013, 09:50 PM
You could use a binary file?
How do you link your program to this PRO/II?
What hooks does PRO/II provide to access data?
Have you considered modules?
I do not understand your question.
[/code] are essential for python code and Makefiles!