Path: news.mathworks.com!newsfeed-00.mathworks.com!solaris.cc.vt.edu!news.vt.edu!news.glorb.com!postnews.google.com!13g2000prl.googlegroups.com!not-for-mail
From: Nathan <ngreco32@gmail.com>
Newsgroups: comp.lang.fortran,comp.soft-sys.matlab
Subject: Re: Fortran formatted read problem (for matlab MEX file)
Date: Fri, 6 Nov 2009 11:05:58 -0800 (PST)
Organization: http://groups.google.com
Lines: 71
Message-ID: <eba3cdeb-43dd-4805-b9fb-b1a320b41323@13g2000prl.googlegroups.com>
References: <7af025a1-6d40-4458-aab0-35bc43418c00@i12g2000prg.googlegroups.com>
NNTP-Posting-Host: 198.206.219.34
Mime-Version: 1.0
Content-Type: text/plain; charset=ISO-8859-1
Content-Transfer-Encoding: quoted-printable
X-Trace: posting.google.com 1257534358 20080 127.0.0.1 (6 Nov 2009 19:05:58 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Fri, 6 Nov 2009 19:05:58 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: 13g2000prl.googlegroups.com; posting-host=198.206.219.34; 
	posting-account=_KeVcAoAAAB7j3xn35ujaQ0BoQhuzwJP
User-Agent: G2/1.0
X-HTTP-Via: 1.1 wwwproxy-son-ca-02.ca.sandia.gov:80 (squid/2.5.STABLE14)
X-HTTP-UserAgent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.1.4) 
	Gecko/20091016 Firefox/3.5.4,gzip(gfe),gzip(gfe)
Xref: news.mathworks.com comp.lang.fortran:213333 comp.soft-sys.matlab:583081


On Nov 6, 10:55 am, Nathan <ngrec...@gmail.com> wrote:
> 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

Ah. One more READ statement that doesn't seem to work. MEX gives me a
message regarding something about input conversion?
"forrtl: severe(64): input conversion error, unit 10, file c:\(OMITTED)
\dippr.dat
etc.

	  IF (NFUEL .GT. 899) THEN
		OPEN (10, FILE = 'dippr.dat', Access = 'sequential',
     +	Form = 'formatted', STATUS = 'unknown')
		NF = -999
		DO WHILE (NF .NE. NFUEL .AND. NF .NE. 0)
			READ(10,301) NF, FUELNAME,MW,TBF,TFCF,PC,VC,ZC,ACEN,ZRA,
     +		ACENW,VCH
		ENDDO
	  ENDIF
 301		FORMAT(I5,A33,3F10.3,E12.4,6F13.5)

Example data in dippr.dat (this example data is all one line):
1003 	METHYL OLEATE                      	296.494	650.930	915.530
1.8565E+02	1.06000	0.21400	1.04940	-1.00000	-1.00000	16.97957