|
forums.silverfrost.com Welcome to the Silverfrost forums
|
View previous topic :: View next topic |
Author |
Message |
DanRRight
Joined: 10 Mar 2008 Posts: 2866 Location: South Pole, Antarctica
|
Posted: Sat Jan 20, 2024 2:16 am Post subject: Poor Fortran ... |
|
|
From the day 1 of my encounter with Fortran i was missing the following functionality: it recognizes its variables by name in the initial settings file (you name it):
Code: | Program ABC
Real : A=0, B=0, C=0
Integer :: i=0, j=0, k=0
LOAD "Variables.dat"
print*, A, B, C, i, j, k
END
|
File Variables.dat contains (or not contains) in any order any variable without any formatting
Code: |
i = 1
k = 3
B = 222.
C =333
j =2
A=111.
|
The result of execution of the code
Code: |
111., 222., 333., i, 2, 3
|
May be it exists and i just missed it for 40 years? |
|
Back to top |
|
|
mecej4
Joined: 31 Oct 2006 Posts: 1896
|
Posted: Sat Jan 20, 2024 2:39 am Post subject: |
|
|
Dan, have you looked at the venerable NAMELIST feature of old Fortran?
With the program
Code: | Program ABC
Real :: A=0, B=0, C=0
Integer :: i=0, j=0, k=0
Namelist /AtoK/A,B,C, i,j,k
Open(10,file='Variables.dat',status='old')
Rewind(10)
read (10, NML = AtoK)
print*, A, B, C, i, j, k
END |
and the data file Variables.dat containing
Code: | &ATOK
i=1
j=2
k=3
A=111.
B=222.
C=333
/
|
you have almost got what you wished for. |
|
Back to top |
|
|
DanRRight
Joined: 10 Mar 2008 Posts: 2866 Location: South Pole, Antarctica
|
Posted: Sun Jan 21, 2024 1:19 am Post subject: |
|
|
Thanks mecej4, i think this is not bad too.
Though would be good to have also the "default" version without declaring namelist (with default namelist to assume ALL variables in the scope of the program where you LOAD variables can be potentially loaded), writing its name inside the dat file and adding slash at the end which people will always forget to do. Because in current approach we still need to remember these rules. And what i see in MATLAB for example is that they broke all the rules and made everything ultimately simple. But I do not know if this is realistically doable
BTW, curious, why you put REWIND there? |
|
Back to top |
|
|
mecej4
Joined: 31 Oct 2006 Posts: 1896
|
Posted: Sun Jan 21, 2024 3:00 am Post subject: |
|
|
Often, when testing new code, it happens that you write a file (with namelist output in this case) REWIND, and try reading back what was just written.
Did you ever spend time rewinding a 1/2 inch tape drive on an old computer? |
|
Back to top |
|
|
DanRRight
Joined: 10 Mar 2008 Posts: 2866 Location: South Pole, Antarctica
|
Posted: Sun Jan 21, 2024 9:57 am Post subject: |
|
|
Experience like with rewinding older tapes happens to me 10 times a day RIGHT NOW with just the usual reading files despite all the modern hardware. Because the files are of gigantic size 0.25-1 TB total. Despite after multiple discussions on this forum the reading speeds now are top notch like PCIe allows, further even minimal sorting of that data on single core is a bottleneck and takes ages. Will need to implement multi-threaded parallel read/sorting with FTN95. |
|
Back to top |
|
|
|
|
You cannot post new topics in this forum You cannot reply to topics in this forum You cannot edit your posts in this forum You cannot delete your posts in this forum You cannot vote in polls in this forum
|
Powered by phpBB © 2001, 2005 phpBB Group
|