Link to home
Start Free TrialLog in
Avatar of prabaharanb
prabaharanb

asked on

How to read input value from file in FORTRAN program?


Hi,
I have written code in FORTRAN language to read values from the input file FILE.txt.
Kindly find the program below:

Program
--------
PROGRAM idl2ftn

    INTEGER i,j
    REAL data(5,3)

  OPEN(UNIT=2, FILE="FILE.txt",FORM="FORMATTED",STATUS="OLD",ACTION="READ")
     READ (2) DATA
      DO 100 j = 1,3
       DO 100 i =1,5
          PRINT *, data
100   CONTINUE
    END

Input file:
-----------
ty FILE.TXT      
0.00000      1.00000      2.00000      3.00000      4.00000
5.00000      6.00000      7.00000      8.00000      9.00000
10.0000      11.0000      12.0000      13.0000      14.0000

When i compiled the code from vms os,it throws error as follows:
%FOR-F-MIXFILACC, mixed file access modes
  unit 1  file USR$DISK:[dev.INPUT]FILE.TXT;1
  user PC 00000000
-FOR-F-UNFIO_FMT, unformatted I/O to unit open for formatted transfers


Please can anyone resolve this issue and provide the solution.
Thanks in advance

Regards,
Prabaharan
ASKER CERTIFIED SOLUTION
Avatar of F. Dominicus
F. Dominicus
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
READ (2,*) DATA
I think 50/50 split would be fair.