Fortran Solving Fortran Input File Problem - B

AI Thread Summary
The discussion revolves around a programming challenge involving the management of key parameters in code. The user seeks to move key parameters from the type declaration section into an external input file for easier access. However, they face a dilemma where certain variables, particularly arrays, cannot be defined until these parameters are known. The program structure restricts the use of file operations, such as opening an input file, before declaring global variables. This creates a circular dependency that complicates the initialization process. A response suggests that the user could use a straightforward approach to open the file and read the parameters, implying that there may be a misunderstanding of the existing code structure. The conversation highlights the need for a solution that allows for the dynamic definition of variables based on external input while adhering to the constraints of the programming environment.
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
 
Technology 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?
 
Dear Peeps I have posted a few questions about programing on this sectio of the PF forum. I want to ask you veterans how you folks learn program in assembly and about computer architecture for the x86 family. In addition to finish learning C, I am also reading the book From bits to Gates to C and Beyond. In the book, it uses the mini LC3 assembly language. I also have books on assembly programming and computer architecture. The few famous ones i have are Computer Organization and...
I had a Microsoft Technical interview this past Friday, the question I was asked was this : How do you find the middle value for a dataset that is too big to fit in RAM? I was not able to figure this out during the interview, but I have been look in this all weekend and I read something online that said it can be done at O(N) using something called the counting sort histogram algorithm ( I did not learn that in my advanced data structures and algorithms class). I have watched some youtube...

Similar threads

Replies
25
Views
3K
Replies
12
Views
3K
Replies
5
Views
2K
Replies
5
Views
5K
Replies
1
Views
3K
Replies
19
Views
6K
Back
Top