Re: Fortran 90 MAT FIle I/O module
- From: Christopher Hulbert <cchgroupmail@xxxxxxxxx>
- Date: Wed, 10 Aug 2005 10:49:45 -0400
Duane Bozarth wrote:
> Christopher Hulbert wrote:
> ...
>
>> err = FMat_Open(filename,mode,mat)
>> IF ( err .EQ. 0 ) THEN
>> ! Read Int32 data
>> err = FMat_VarReadInfo(mat,i32name,matvar)
>> IF ( err .EQ. 0 ) THEN
>> err = FMat_VarReadInfo(mat,matvar,i32)
>> PRINT *,i32
>> err = FMat_VarFree(matvar)
>> ELSE
>> PRINT *,'Could not read variable',i32name
>> ENDIF
>> ! Read Int16 data
>> IF ( err .EQ. 0 ) THEN
>> err = FMat_VarReadInfo(mat,i16name,matvar)
>
> ....
>
> Looks to me like this isn't probably what you really want logically.
> This will drop through trying to read each type in sequence. Don't
> recall what FMat_VarReadInfo returns for error conditions but doesn't it
> (or another API) tell you the type of data and shouldn't you select the
> proper data size based on that?
FMat_VarReadInfo is my api, it returns 0 on success, non-zero on error. None of my code relies on
matlab functions, so you can disregard any thought of Matlab's API. Yes, the intent was to
sequentially try to read variables from a file. And just because FMat_VarReadInfo fails on
int32name (let's say because the variable didn't exist) doesn't mean it won't succeed for int16name.
>
> As written, also if there were an error after the FMat_VarReadInfo in
> the 32-bit int section, it would still drop through to the Int16 section
> and the err variable would still be nonzero so it would just keep
> dropping on the the "else" clauses. At a minimum one would need to
> reset err = 0 before attempting the other read but I'm thinking that's a
> mistake to be at that point anyway at that point.
Yes, I just added those error tests before posting and good old copy/paste without reanalyzing the
code is the culprit. I compiled but didn't run it.
>
> It isn't clear to me what your overall intent is to comment on what it
> should be...
The intent is to test reading a variable from a MAT file and print the data to the screen.
Since syntax/etc IS off-topic in cssm, moving to an appropriate medium like clf or email would
probably be more appropriate for those. Thank you for the help.
.
- Follow-Ups:
- Re: Fortran 90 MAT FIle I/O module
- From: Duane Bozarth
- Re: Fortran 90 MAT FIle I/O module
- References:
- Fortran 90 MAT FIle I/O module
- From: Christopher Hulbert
- Re: Fortran 90 MAT FIle I/O module
- From: Duane Bozarth
- Fortran 90 MAT FIle I/O module
- Prev by Date: Re: Fortran 90 MAT FIle I/O module
- Next by Date: image acquisition with Matlab using Linux
- Previous by thread: Re: Fortran 90 MAT FIle I/O module
- Next by thread: Re: Fortran 90 MAT FIle I/O module
- Index(es):
Relevant Pages
|