Solving Fortran Input File Problem - B

  • Context: Fortran 
  • Thread starter Thread starter Nrets
  • Start date Start date
  • Tags Tags
    File Fortran Input
Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
1 reply · 4K views
Nrets
Messages
1
Reaction score
0
Hey guys,

I am wondering if anyone could help me with a simple problem.

I want to remove key parameters from the "type declaration/parameter" portion of my code and into an external input file for easy access. The problem is, many of my variables (such as arrays) can't be defined until these key parameters are known. However, the program structure disallows a function like "open" in or before the array declarations. In other words, I can only open an input file after I have defined all my global variables. But I can't define all my global variables without opening the input file.

There has to be a solution, yes? Any help would be appreciated.

- B
 
Physics news on Phys.org
Sorry, I did not understand how you could not simply put some code like

Code:
Open (Unit=1, File='File.dat')
Read(1,*)var1
Read(1,*)var2
.
.
.
Read(1,*)varn
Close (Unit=1)

Mainly because you already use some Write\Reads, if I'm guessing right. Maybe some allocatable array? Could you show this bit of code?