New to fortran, so this may be trvial....
I want to read specific bits of data from a file. See the two files below, I want to read certain values, for example, the line after burner. But the line on which a particular value appears will have changed from one file to another. In one file the data for the burner is on line 8, on the other it is on line 10.
************file 1***********
INTAKE
0.00000E+00 0.00000E+00 0.00000E+00 0.10000E+01
COMPRE
0.85000E+00 0.10000E+01 0.12700E+02 0.88000E+00 0.00000E+00 4 0.00000E+00
PREMAS
0.90000E+00 0.00000E+00 0.10000E+01 0.00000E+00
BURNER
0.76200E+00 0.99000E+00 0.61161E+01
TURBIN
0.87300E+08 0.41435E+03 0.20600E+01 0.89000E+00 0.10000E-03 0.10000E+01 4 0.10000E+04 0.10360E+09 0.00000E+00
NOZCON
0.40225E+01
PERFOR
0.87300E+08 0.10000E+01 0.10000E+01 0.87300E+08 0.00000E+00 0.00000E+00 0.61161E+01 0.00000E+00 0.00000E+00 0.00000E+00
0.00000E+00 0.00000E+00 0.00000E+00
********file 2***********
INTAKE
0.00000E+00 0.00000E+00 0.00000E+00 0.10000E+01
COMPRE
0.85000E+00 0.10000E+01 0.50000E+01 0.84000E+00 0.10000E+01 5 0.00000E+00
DUCTER
0.20000E+01 0.25000E+00 0.10000E+01 0.00000E+00
COMPRE
0.85000E+00 0.10000E+01 0.84000E+01 0.84000E+00 0.00000E+00 5 0.00000E+00
BURNER
0.19950E+01 0.99000E+00 0.53542E+01
TURBIN
0.00000E+00 0.21963E+03 0.22000E+01 0.90000E+00 0.10000E-03 0.20000E+01 5 -0.10000E+01 0.83370E+08 0.00000E+00
TURBIN
0.00000E+00 0.21963E+03 0.22000E+01 0.90000E+00 0.10000E-03 0.10000E+01 5 -0.10000E+01 0.41216E+08 0.00000E+00
TURBIN
0.10000E+09 0.21963E+03 0.22000E+01 0.90000E+00 0.10000E+01 0.00000E+00 5 -0.10000E+01 -0.10000E+01 0.00000E+00
NOZCON
0.42348E+01
PERFOR
0.10000E+09 -0.10000E+01 0.10000E+01 0.10000E+09 0.22212E+05 0.00000E+00 0.53542E+01 0.00000E+00 0.00000E+00 0.00000E+00
0.00000E+00 0.00000E+00 0.00000E+00
***********************************************
Each file represents a different engine, so the number of lines changes and so does the position of the specific bit of data corresponding to a certain part of the engine.
I think I need to read a specific word like burner, and identify this word and then read the next line or something. How do I do this? How do I ‘find’ a word in a file I’m reading from?
In the end, I want one code which is able to read from any length/buildup of input file, so the code should read certain values regardless of number of data in each loop and which line the data appear on.
thanks
Saqib
I want to read specific bits of data from a file. See the two files below, I want to read certain values, for example, the line after burner. But the line on which a particular value appears will have changed from one file to another. In one file the data for the burner is on line 8, on the other it is on line 10.
************file 1***********
INTAKE
0.00000E+00 0.00000E+00 0.00000E+00 0.10000E+01
COMPRE
0.85000E+00 0.10000E+01 0.12700E+02 0.88000E+00 0.00000E+00 4 0.00000E+00
PREMAS
0.90000E+00 0.00000E+00 0.10000E+01 0.00000E+00
BURNER
0.76200E+00 0.99000E+00 0.61161E+01
TURBIN
0.87300E+08 0.41435E+03 0.20600E+01 0.89000E+00 0.10000E-03 0.10000E+01 4 0.10000E+04 0.10360E+09 0.00000E+00
NOZCON
0.40225E+01
PERFOR
0.87300E+08 0.10000E+01 0.10000E+01 0.87300E+08 0.00000E+00 0.00000E+00 0.61161E+01 0.00000E+00 0.00000E+00 0.00000E+00
0.00000E+00 0.00000E+00 0.00000E+00
********file 2***********
INTAKE
0.00000E+00 0.00000E+00 0.00000E+00 0.10000E+01
COMPRE
0.85000E+00 0.10000E+01 0.50000E+01 0.84000E+00 0.10000E+01 5 0.00000E+00
DUCTER
0.20000E+01 0.25000E+00 0.10000E+01 0.00000E+00
COMPRE
0.85000E+00 0.10000E+01 0.84000E+01 0.84000E+00 0.00000E+00 5 0.00000E+00
BURNER
0.19950E+01 0.99000E+00 0.53542E+01
TURBIN
0.00000E+00 0.21963E+03 0.22000E+01 0.90000E+00 0.10000E-03 0.20000E+01 5 -0.10000E+01 0.83370E+08 0.00000E+00
TURBIN
0.00000E+00 0.21963E+03 0.22000E+01 0.90000E+00 0.10000E-03 0.10000E+01 5 -0.10000E+01 0.41216E+08 0.00000E+00
TURBIN
0.10000E+09 0.21963E+03 0.22000E+01 0.90000E+00 0.10000E+01 0.00000E+00 5 -0.10000E+01 -0.10000E+01 0.00000E+00
NOZCON
0.42348E+01
PERFOR
0.10000E+09 -0.10000E+01 0.10000E+01 0.10000E+09 0.22212E+05 0.00000E+00 0.53542E+01 0.00000E+00 0.00000E+00 0.00000E+00
0.00000E+00 0.00000E+00 0.00000E+00
***********************************************
Each file represents a different engine, so the number of lines changes and so does the position of the specific bit of data corresponding to a certain part of the engine.
I think I need to read a specific word like burner, and identify this word and then read the next line or something. How do I do this? How do I ‘find’ a word in a file I’m reading from?
In the end, I want one code which is able to read from any length/buildup of input file, so the code should read certain values regardless of number of data in each loop and which line the data appear on.
thanks
Saqib