Path: news.mathworks.com!newsfeed-00.mathworks.com!newsfeed2.dallas1.level3.net!news.level3.com!postnews.google.com!f1g2000prf.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 12:09:36 -0800 (PST)
Organization: http://groups.google.com
Lines: 99
Message-ID: <dd6e3ab8-fd69-4aba-bfc7-377b2392841d@f1g2000prf.googlegroups.com>
References: <7af025a1-6d40-4458-aab0-35bc43418c00@i12g2000prg.googlegroups.com> 
	<hd1sg5$u5k$1@news.eternal-september.org> <d039a82a-256d-411d-a100-2b07c196cb0f@2g2000prl.googlegroups.com> 
	<hd1v00$kib$1@news.eternal-september.org>
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 1257538176 5924 127.0.0.1 (6 Nov 2009 20:09:36 GMT)
X-Complaints-To: groups-abuse@google.com
NNTP-Posting-Date: Fri, 6 Nov 2009 20:09:36 +0000 (UTC)
Complaints-To: groups-abuse@google.com
Injection-Info: f1g2000prf.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:213342 comp.soft-sys.matlab:583106


On Nov 6, 11:55 am, dpb <n...@non.net> wrote:
> Nathan wrote:
>
> ...
>
> > Hm. Alright. My data files do contain tabs, as I wanted to make them
> > in a readable format. (They were created through Matlab, after reading
> > in real data sheets and extracting information). Perhaps I'll try to
> > find a way to remedy that first. Thanks for pointing that out to me. I
> > think I understand how the formatting is supposed to work now, but
> > I'll definitely be back when more errors occur.
>
> Well, fixing that is pretty easy, just don't write tabs... :)
>
> > My variable declarations are spread across multiple files, I think.
> > (The code I am working on was passed down to me by previous student
> > interns, and I am still trying to figure it out. I have no fortran
> > experience beyond the last couple of months, reading this code)
>
> > Some of my variables seem to just appear out of nowhere, with no data
> > type declaration... Could this be a problem?
>
> ...
>
> Possibly, remember implicit typing rules are i-n are integers by default.
>
> The strongest thing to do would be to add
>
> IMPLICIT NONE
>
> to each routine, but that will undoubtedly require quite some time to
> sort out all the errors that will suddenly show up.  But, then again, it
> could potentially find real errors as well.
>
> The arrays will have to have been declared somewhere/somehow in order to
> have become arrays.  One would presume they were declared as floats of
> default or double precision, but then again, mistakes have been known to
> be made...
>
> --

In my main routine, a separate file from my MEX driver file, I have
this:
	SUBROUTINE LIQVAP(IDB,NFUEL,NGAS,MTYPE,MNUM,XL, XLIQret, TSATret,
	+BTret, NCOMP,ICOMPG,MWG,TCGF,PCG,ACENG,CONC,TCGC,tanang,FUELNAME,
     +ICOMP,MW,TBF,TFCF,PC,ZC,ACEN,ZRA,ACENW,VCH,zz,TFCC)

      IMPLICIT DOUBLE PRECISION (A-H,O-Z)
      DOUBLE PRECISION MW, MWG(5), MWMG, MCONC(5), MCONCSUM
	DOUBLE PRECISION IGCOEF(5), LDCOEF(4) !DIPPR equation coefficient
variables
      DIMENSION ICOMPG(5), ACENG(5), TCGC(5), TCGF(5), XL(20)
      DIMENSION PCG(5), CONC(5), ENTHIGG(5), VCG(5), ZCG(5)
      DIMENSION IER(11), IERF(7), IERZ1(4), IERZ2(4),IERZ3(4),IERZ4(4)
      CHARACTER FUELNAME*45

In the routine used to read in the dippr.dat, I only have
	SUBROUTINE FUELSDAT (NFUEL, FUELNAME,ICOMP,MW,TBF,TFCF,PC,ZC,
     +             ACEN,ZRA,ACENW,VCH,zz,TFCC)

	IMPLICIT DOUBLE PRECISION (A-H,M,O-Z)
	CHARACTER FUELNAME*45

In my driver file, as a subroutine (which calls LIQVAP), I have this:
	SUBROUTINE liqvapMex(XLIQ,TSAT, BT, nsteps,conv_nfuel,tanang,Ca,
	+					 DCONC,Ta,rhoa,Tfuel,Snozzle)

	IMPLICIT DOUBLE PRECISION (A-H,O-Z)
	DIMENSION Ta(0:nsteps), rhoa(0:nsteps), Tfuel(0:nsteps)
	DIMENSION Snozzle(0:nsteps), pressure(0:nsteps), XL(20)
	DIMENSION XLIQ(0:nsteps), TSAT (0:nsteps), BT (0:nsteps)
	DIMENSION DCONC(1:5)
	DIMENSION ICOMPG(5), ACENG(5), TCGC(5), TCGF(5),PCG(5), CONC(5)
	DOUBLE PRECISION MW, MWG(5)
	CHARACTER FUELNAME*45

and call the FUELSDAT routine as such (within this liqvapmex
subroutine):
	CALL FUELSDAT (NFUEL, FUELNAME,ICOMP,MW,TBF,TFCF,PC,ZC,
     +             ACEN,ZRA,ACENW,VCH,zz,TFCC)

Notice that ICOMP,TBF,TFCF,PC,ZC,ACEN,ZRA,ACENW,VCH,zz, and TFCC are
all "poofed" into existence (according to the IMPLICIT DOUBLE
PRECISION declaration above, I presume)

I fixed the formatting for each of my data files to correctly match
the format statements.
The only one I might be concerned with is the E format terms regarding
numbers such as:
     9.7160E+02 and the like.
I used the format statement %E15.4  such that from the first white
space until the last digit (2), there are 15 characters and 4
decimals. Is that correct?

I am still receiving errors when trying to run with MEX.

-Nathan