Re: Read/Write Matlab files in fortran



Rather than:
- Set the type of variable
- Read the data into the variable

I would use an interface to some generic routine to hide these details.
That is:

interface fmat_varread
module procedure fmat_varread_short_int
module procedure fmat_varread_int
...
end interface

and the module defines fmat_varread_int etc. like:

integer function fmat_varread_int( ... )
err = FMAT_VARREADINFO(mat,'i32',matvar)
IF ( err .EQ. 0 ) THEN
err = FMAT_VARREADDATA(mat,matvar,i32)
END IF

fmat_varread_int = err
end function

In other words: let the compiler worry about as many details
as you can possibly get away with, making it easier for the
human user of your library.

Regards,

Arjen

.



Relevant Pages

  • Re: why doesnt this compile ?
    ... You either have an interface body or use a module procedure statement. ... If you have a procedure whose interface is already explicit, but which is not a module procedure, then this is awkward. ... "module procedure" in the main program is a compiler *extension*, ...
    (comp.lang.fortran)
  • Re: Interface declarations
    ... That is much stronger than being redundant. ... say in the main program - is an interface declaration. ... MODULE PROCEDURE xyz ... SUBROUTINE xyz ...
    (comp.lang.fortran)
  • Re: Vector Algebra Module
    ... transformations, projections, and least squares solutions ... cartesian coordinates, but for determining the interference pattern ... interface operator ... module procedure rotate_3d_point ...
    (comp.lang.fortran)
  • Re: Interface declarations
    ... MODULE PROCEDURE flux_godunov ... This is one of that kind of interface block. ... I haven't yet mentioned the extra oddity in this particular case. ... I personally regard that as very confusing. ...
    (comp.lang.fortran)
  • Re: generic interface question
    ... END INTERFACE ... Cannot change attributes of USE-associated symbol 'foo1' at ... the critical bit here is that foo1 is *NOT* a module procedure. ... Or put a generic interface block for foo in module a, ...
    (comp.lang.fortran)