Savan Gowda
Savan Gowda

Reputation: 11

Program compiling but not printing results

I have been trying to write a program in Fortran77 and am not able to finish it up, so I need a bit help to make it work. At first I am just trying to open a .txt file read the file and write the file. the .txt file is of the format shown below.

001,0.02014,3.1217    
002,0.09611,3.1203    
003,0.23753,3.1128
004,0.45527,3.0884    
005,0.75772,3.0285

where the first column is integer and the second column coma separated contains a real number with 5 digits after the decimal point and third column again a real number with four digits after the decimal point.

My program looks as follows:

      PROGRAM FIRST
      IMPLICIT NONE

      REAL,DIMENSION(304,3)::A 

      OPEN(UNIT =7 , FILE = "Pressure_values.txt",
     1 FORM = "FORMATTED", STATUS = "OLD", ACTION = "READ") 

      READ(*,100) ((A(I,J),J=1,3), I=1,304) 

      WRITE(*,100) ((A(I,J),J=1,3), I=1,304)

   100 FORMAT(I3,F10.5,F10.4)

      STOP

      END

Where am I going wrong?

Upvotes: 0

Views: 139

Answers (2)

user2545464
user2545464

Reputation: 191

your code:

READ(*,100) ((A(I,J),J=1,3), I=1,304) 

means "read from STDIN with format No.100", not the file you just opened. STDIN normally means the keyboard input stream. use:

READ(7,100) ((A(I,J),J=1,3), I=1,304) 

instead.

Upvotes: 0

Fl.pf.
Fl.pf.

Reputation: 345

You are not reading from the file. You need to read from unit 7.

read(7,100)

Upvotes: 3

Related Questions