Hi,
I do have a problem to write a Fortran program to select data from a huge data set as follows:
1.500D+00 1.000D+06 3.000D+06 5.000D+06 7.000D+06 9.000D+06 1.100D+07 1.300D+07
1.500D+07 1.700D+07 1.900D+07 2.100D+07 2.300D+07 2.500D+07 2.700D+07 2.900D+07
3.100D+07 3.300D+07 3.500D+07 3.700D+07 3.900D+07 4.100D+07 4.300D+07 4.500D+07
4.700D+07 4.900D+07 5.100D+07 5.300D+07 5.500D+07 5.700D+07 5.900D+07 6.100D+07
1.750D+08 1.770D+08 1.790D+08 1.810D+08
2.000D+00 1.000D+06 3.000D+06 5.000D+06 7.000D+06 9.000D+06 1.100D+07 1.300D+07
1.500D+07 1.700D+07 1.900D+07 2.100D+07 2.300D+07 2.500D+07 2.700D+07 2.900D+07
3.100D+07 3.300D+07 3.500D+07 3.700D+07 3.900D+07 4.100D+07 4.300D+07 4.500D+07
4.700D+07 4.900D+07 5.100D+07 5.300D+07 5.500D+07 5.700D+07 5.900D+07 6.100D+07
1.750D+08 1.770D+08 1.790D+08 1.810D+08
2.500D+00 1.000D+06 3.000D+06 5.000D+06 7.000D+06 9.000D+06 1.100D+07 1.300D+07
1.500D+07 1.700D+07 1.900D+07 2.100D+07 2.300D+07 2.500D+07 2.700D+07 2.900D+07
3.100D+07 3.300D+07 3.500D+07 3.700D+07 3.900D+07 4.100D+07 4.300D+07 4.500D+07
4.700D+07 4.900D+07 5.100D+07 5.300D+07 5.500D+07 5.700D+07 5.900D+07 6.100D+07
1.750D+08 1.770D+08 1.790D+08 1.810D+08
.....
....
....
The data consists of blocks (without spaces), the number of blocks is not known, each block contains 36 numbers, my problem is to select certain numbers from each block say B1(1)B1(20),B1(33) and put all data from all blocks under each other as:
B1(1) B1(20) B1(33)
B2(1) B2(20) B2(33)
B3(1) B3(20) B3(33)
..................
Can anybody help please,
Thanks in advance
Comments
and FORMAT statements. You don't write about how
each block is laid out or my browser just makes
it look different.
[code]C
INTEGER*4 I,J,X
C
DOUBLE B(36,100)
C
C ASSIGN THE UNIT NUMBER OF THE FILE. THERE SHOULD BE SOME KIND OF
C END OF FILE(EOF) THAT YOU CAN TEST FOR
C
X = 10
C
C
DO 10 J = 1 TO 100
READ(UNIT=X,FMT=9000) (B(I,J),I=1,36,1)
9000 FORMAT(36D10.3)
C I MAY NOT HAVE THE FORMAT EXACTLY RIGHT
10 CONTINUE
C
C THE OTHER DISPLAY PART I'LL LEAVE TO YOU
C[/code]
Thanks very much for the quick reply, I have adopted the program and it seems to work with small problem: The number of blocks is set to a large number (e.g., 1000) and thus if the number of blocks less than 1000, the output contains zeros for the rest (which is not required).
Is there any way to detect the number of blocks and also write it out.
How can I eliminate the zeros?
Here is the program and a sample output.
program recon
INTEGER*4 I,J,X
DOUBLE B(92,1000)
C
OPEN(UNIT=10, FILE='fourier.dat',STATUS='OLD')
OPEN(UNIT=15, FILE='fourier.out',STATUS='replace')
C
DO 10 J = 1, 1000
READ(10,9000,end=15) (B(I,J),I=1,92,1)
9000 FORMAT(1p,8d10.3)
10 CONTINUE
C
15 CONTINUE
DO 20 J = 1, 1000
write(15,9005) (B(I,J),I=1,92,30)
9005 FORMAT(1p,4d10.3)
20 CONTINUE
end
----------------------
Output
8.640D+00 5.900D+07 1.190D+08 1.790D+08
8.760D+00 5.900D+07 1.190D+08 1.790D+08
8.880D+00 0.000D+00 0.000D+00 0.000D+00
0.000D+00 0.000D+00 0.000D+00 0.000D+00
0.000D+00 0.000D+00 0.000D+00 0.000D+00
0.000D+00 0.000D+00 0.000D+00 0.000D+00
0.000D+00 0.000D+00 0.000D+00 0.000D+00
0.000D+00 0.000D+00 0.000D+00 0.000D+00
0.000D+00 0.000D+00 0.000D+00 0.000D+00
--------------
Many thanks in advance,
and stop the loop from going on. When that happens, take the
value of [italic]J[/italic] and [italic]subtract 1[/italic] to have tthe number of blocks read in. Then have the 2nd loop go from [italic]1[/italic] to [italic]J-1[/italic] using another index.
: and stop the loop from going on. When that happens, take the
: value of [italic]J[/italic] and [italic]subtract 1[/italic] to have
: tthe number of blocks read in. Then have the 2nd loop go from
: [italic]1[/italic] to [italic]J-1[/italic] using another index.
:
Thanks a lot for your help... It works now