Re: Fortran 90 MAT FIle I/O module



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.

.



Relevant Pages

  • Re: Help understanding how winapi works
    ... My intent is to learn how the api works, not how to use the api ... I want to know the "A message is sent to the windows subsystem" part. ... The exact details depends on the exact API. ...
    (microsoft.public.win32.programmer.kernel)
  • Re: [patch 1/3] x86: a new API for drivers/etc to control cache and other page attributes
    ... the only API they have is change_page_attr. ... transparently handled in c_p_ano matter what the caller passes in. ... The new API is a lot simpler, and it is INTENT driven. ... This means that PAT no longer has to second guess various things ...
    (Linux-Kernel)
  • [Request for Comments] PMC(3) API
    ... I would like to solicit comments on the following API for using CPU ... performance monitoring counters in FreeBSD. ... The intent is to use this API to support PAPI and other 'portable' ...
    (freebsd-performance)
  • C++ API for MAT-File
    ... Is there any C++ API for opening MAT-Files? ... of mxArray and the only API I can find for reading .mat file is in C. ...
    (comp.soft-sys.matlab)