[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 960627 Fortan-90 module



>From: Robert Pincus <address@hidden>
>Subject: Fortran-90 module for netCDF API
>Organization: Climate and Radiation Branch, NASA Goddard Space Flight Center
>Keywords: 199606271905.AA04392

Robert,

> I've attached my very minor revisions to the merged version of the netCDF
> API Fortran-90 module you sent me yesterday. I've commented out the
> interface blocks for routines which use type-punning or rank-punning, and
> made some other small changes (declaring several variables on a line,
> using the dimension attribute in declarations rather than a variable(*)
> form). I've compiled this on my SGI with no problems, so the code is
> legal. I can't guaruntee that it is correct, though. 

That's great, thanks!  I've checked your revised version in so it will be
included with the next update.

> The treatment of subroutines like ncvpt in Fortran-90 is going to be very
> hard. The problems, of course, are two-fold: not only can the values
> argument have any legal type, but it may be of any legal rank (number of
> dimensions) as well. The function could be "overloaded" in Fortran-90, but
> that would involve writing separate underlying routines for every variable
> type/array rank combination. Ick. I'm not aware of ways to allow arbitray
> ranks or arbitrary types in F90, but I'll keep my eyes peeled.

I knew the varied type was a problem that would be fixed by our new
"type-safe" Fortran interface that will be in netCDF version 3.0 (where we
define versions of the get/put routines for every Fortran type, and these
routines do conversion, so you can always ask for the data as "real" and it
will be converted to real even if it happens to be stored as NC_SHORT or
NC_DOUBLE).  However, I didn't realize Fortran-90 required the ranks to
match.  This seems wrong to me, as you might want to call a linear equation
solver with a matrix that was really just a 2-D slice of a 5-D array, and
you shouldn't have to copy the coefficient matrix into a 2-D array first or
equivalence it to a 2-D variable to use a linear equation solver in a
library that has an interface block calling for a 2-D array of
coefficients.

> On the other hand, Fortran-90 might offer some improved runtime error
> checking and simplification of some arguments. Overloading could provide
> some neat opportunities, too - one example would be allowing a character
> string in the varid argument to many procedures, which would be
> interpreted as "the variable number in the current netCDF file with this
> name". I don't know what level of resources you have available to devote
> to things like this, though. 

We're rapidly forgetting all our Fortran, and I'm so enamored of Java that
I may soon forget all my C and C++ as well.  Oh well, I guess we're living
on "Internet years" that are like dog years, one year seems like seven in
terms of the rate of change, and it's accelerating ...

--Russ