New programming languages

Moderators: None (Apply to moderate this forum)
Number of threads: 111
Number of posts: 329

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
Urgent: problem with data selection Posted by anton2010 on 16 Sept 2010 at 6:12 AM
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
Report
Re: Urgent: problem with data selection Posted by quikcarl on 16 Sept 2010 at 4:13 PM
Maybe this will help. Don't be afraid of READ
and FORMAT statements. You don't write about how
each block is laid out or my browser just makes
it look different.
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


Report
Re: Urgent: problem with data selection Posted by anton2010 on 17 Sept 2010 at 2:34 AM
Hi,
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,

Report
Re: Urgent: problem with data selection Posted by quikcarl on 17 Sept 2010 at 6:17 PM
Okay, the END part in the READ statement should work
and stop the loop from going on. When that happens, take the
value of J and subtract 1 to have tthe number of blocks read in. Then have the 2nd loop go from 1 to J-1 using another index.
Report
Re: Urgent: problem with data selection Posted by anton2010 on 20 Sept 2010 at 4:11 AM
: Okay, the END part in the READ statement should work
: and stop the loop from going on. When that happens, take the
: value of J and subtract 1 to have
: tthe number of blocks read in. Then have the 2nd loop go from
: 1 to J-1 using another index.
:
Thanks a lot for your help... It works now
Report
This post has been deleted. Posted by anton2010 on 17 Sept 2010 at 2:35 AM
This post has been deleted.



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.