oakleybloke
Technical User
I am trying to read in data from an output file that has the form:
MAP=======================================================================================
Map of PRESSURE at 2 Jan 2000, 1.0 days
==========================================================================================
Layer iz= 1
ix= : 1 2 3 4 5
Row iy= 1: 298.888 298.888 298.888 298.888 298.888
Row iy= 2: 298.888 298.888 298.888 298.888 298.888
Row iy= 3: 298.888 298.888 298.888 298.888 298.889
Row iy= 4: 298.888 298.888 298.888 298.888 298.889
Row iy= 5: 298.888 298.888 298.888 298.888 298.889
I have tried using an implicit do loop, and a format statement to ignore the 'Row iy= 1: part and then read the next values using further format statements. At the moment my code for the format statement is:
29 FORMAT(13X,F7.3,2X,F7.3,2X,F7.3,2X,F7.3,2X,F7.3,2X,F7.3,2X,F7.3
+,2X,F7.3,2X,F7.3,2X,F7.3,2X,F7.3,2X,F7.3,2X,F7.3,2X,F7.3,2X,F7.3
+,2X,F7.3,2X,F7.3,2X,F7.3,2X,F7.3,2X,F7.3,2X,F7.3,2X,F7.3,2X,F7.3
+,2X,F7.3,2X,F7.3,2X,F7.3,2X,F7.3,2X,F7.3,2X,F7.3,2X,F7.3)
So I skip the first 13 characters, reads the number, skips the next character and reads the number and so on.
My problem is that this is specific to the dimensions of the array and generally seems a bit ridiculous, is there a way to write format statements so that they include parameters such as the size of the array? Or should I be trying something completely different? My only other thought is that I could generate the code for the format statement somehow, using the array parameters, but I am unsure how to do this, and include it in my program.
I am also using FORTRAN 77.
Thanks Tom
MAP=======================================================================================
Map of PRESSURE at 2 Jan 2000, 1.0 days
==========================================================================================
Layer iz= 1
ix= : 1 2 3 4 5
Row iy= 1: 298.888 298.888 298.888 298.888 298.888
Row iy= 2: 298.888 298.888 298.888 298.888 298.888
Row iy= 3: 298.888 298.888 298.888 298.888 298.889
Row iy= 4: 298.888 298.888 298.888 298.888 298.889
Row iy= 5: 298.888 298.888 298.888 298.888 298.889
I have tried using an implicit do loop, and a format statement to ignore the 'Row iy= 1: part and then read the next values using further format statements. At the moment my code for the format statement is:
29 FORMAT(13X,F7.3,2X,F7.3,2X,F7.3,2X,F7.3,2X,F7.3,2X,F7.3,2X,F7.3
+,2X,F7.3,2X,F7.3,2X,F7.3,2X,F7.3,2X,F7.3,2X,F7.3,2X,F7.3,2X,F7.3
+,2X,F7.3,2X,F7.3,2X,F7.3,2X,F7.3,2X,F7.3,2X,F7.3,2X,F7.3,2X,F7.3
+,2X,F7.3,2X,F7.3,2X,F7.3,2X,F7.3,2X,F7.3,2X,F7.3,2X,F7.3)
So I skip the first 13 characters, reads the number, skips the next character and reads the number and so on.
My problem is that this is specific to the dimensions of the array and generally seems a bit ridiculous, is there a way to write format statements so that they include parameters such as the size of the array? Or should I be trying something completely different? My only other thought is that I could generate the code for the format statement somehow, using the array parameters, but I am unsure how to do this, and include it in my program.
I am also using FORTRAN 77.
Thanks Tom