Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: Fortran formatted read problem (for matlab MEX file)
Date: Fri, 6 Nov 2009 22:02:02 +0000 (UTC)
Organization: Boeing
Lines: 11
Message-ID: <hd26cq$s30$1@fred.mathworks.com>
References: <7af025a1-6d40-4458-aab0-35bc43418c00@i12g2000prg.googlegroups.com> <57826745-9026-4025-a5d2-90b67cd03802@g22g2000prf.googlegroups.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1257544922 28768 172.30.248.35 (6 Nov 2009 22:02:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Fri, 6 Nov 2009 22:02:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 756104
Xref: news.mathworks.com comp.soft-sys.matlab:583136


Nathan <ngreco32@gmail.com> wrote in message <57826745-9026-4025-a5d2-90b67cd03802@g22g2000prf.googlegroups.com>...
> 
> As I mentioned before, there is no close statement. Would that cause
> this error? If so, where would I place the close?
> After the loop of reading?

The short answer is you should close the file after you are done reading it. This is particularly important in a mex routine. When you first run the mex routine, the dll is loaded into memory and then executed. When the mex routine returns to MATLAB, the dll *remains* loaded in memory. Any open files remain open. It's not like running a Fortran program and hitting the end of the program, in which event open files are automatically closed for you (i.e., they become available for another program to open). So if you subsequently try to open this file with another function it may not work.

As far as the floating point formats are concerned, there are a lot of subtle rules that you can get caught up with involving F, E, E, EN, decimal point or no decimal point, etc. etc. You can waste a lot of time trying to understand all of that. Rather than spending your time with it at this point, I would advise simply using an E format for both input & output with enough characters to get the precision you need.

James Tursa