|
|
Fortran formatted read problem (for matlab MEX file)
Posted:
Nov 6, 2009 1:55 PM
|
|
Hi. I don't know Fortran well enough to do file i/o, let alone formatted file i/o. I am trying to read data into my fortran code that is to be used for calculations that will be returned to Matlab. What I have tried, and what doesn't seem to work is as follows: NFUEL is the fuel number (look at data example below. 1003 corresponds to METHYL OLEATE)
IF (NFUEL .GT. 1000) THEN OPEN(13, FILE = 'dipprig.dat', Access = 'sequential', + Form = 'formatted', STATUS = 'unknown') OPEN(14, FILE = 'dipprld.dat', Access = 'sequential', + Form = 'formatted', STATUS = 'unknown') 20 FORMAT(I5,A33,5EN12.4) 21 FORMAT(I5,A33,4EN12.4) NF = -999 DO WHILE (NF .NE. NFUEL .AND. NF .NE. 0) !Read IG READ(13,20) NF, FUELNAME,IGCOEF(1),IGCOEF(2),IGCOEF(3), + IGCOEF(4),IGCOEF(5) ENDDO NF = -999 DO WHILE (NF .NE. NFUEL .AND. NF .NE. 0) !Read LD READ(14,21) NF, FUELNAME,LDCOEF(1),LDCOEF(2),LDCOEF(3), + LDCOEF(4) ENDDO ENDIF
Examples of the corresponding data files are as follows (the data is contained within 1 line, for each file) (dipprig.dat data example): 1003 METHYL OLEATE 3.2997E+05 9.7160E +05 1.6456E+03 6.7448E+05 7.4800E+02
(dipprld.dat data example): 1003 METHYL OLEATE 2.4755E-01 2.6240E-01 7.6400E+02 3.3247E-01
The data values may contain a - in front of them, depending on the fuel. If there is any more information you need to help me, please ask. I know that this doesn't work because while debugging, nothing is read into the variables.
-Nathan
|
|