Re: [netcdfgroup] Building netcdf-4 programs with F90

Roy Mendelssohn <Roy.Mendelssohn@xxxxxxxx> writes:

> Hi Russ:
>
> I have the snapshot of netcdf4 as of 2008031112. I am using the F90  
> interface  (Intel Macbook pro, the gcc hat comes with Xcode and  
> gfortran), and other than changing my prefix, I have done everything  
> by default, except for including the szlib library in hdf5..  So  
> given that, I have found:
>
> 1.  A number of the examples for F90, in terms of the modules, only have
>
>        use netcdf
>
> I found that this produces an error in my own code  (the module was  
> found, so that is not the error), and programs would only compile if  
> both modules were used and in this order only:
>
>     use typesizes
>     use netcdf

Could you tell me which ones?

A diff on the directory would also work.

>
> 2. In linking, I had to explicitly list netcdf, hdf_hl, hdf, z and sz  
> as the libraries to link in, otherwise I would get an undefined  
> reference.

Yep. That's because all these libraries are used.

> I have already sent an email that how to do Vlen's in fortran is very  
> unclear - somehow the data needs to be stuffed into a character  
> buffer  (what HDF fortran has done for awhile) but it is very unclear  
> how to map data into the given calls.  Groups and subgroups, and  
> straightforward data puts so far are working fine.
>

Well, I can't make working on fortran easy. I'll be happy to make it
possible. ;-)

Basically you have to create the same byte layout as would be created
by the C compiler on your platform, using structs. This is platform
dependent.

But when you write those structs to the HDF5 file, a platform
independent mapping is used.

For C, the HDF5 library has a way of figuring it out at HDF5 build
time, and then maintaining a mapping. 

But how can this be done for Fortran 77? No structs.

Theoretically it could be done for F90 data structures, but this has
not been done and may not be done any time soon.

So the fortran answer is to map out your data in memory, and make sure
you get it correct.

This is not much different from doing the same thing with a straight
binary file. If you want to have these complex data structures in
fortran, there's a lot of work involved. I don't think I can improve
on that in the near term.

Thanks,

Ed
-- 
Ed Hartnett  -- ed@xxxxxxxxxxxxxxxx


  • 2008 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdfgroup archives: