Skip to content

some suggestions from Richard Weed, author of F90 API #153

Open
@edhartnett

Description

Here's an email I got from Richard Weed, who wrote the F90 API many years ago. Some of these suggestions seem promising and I will take a look when I have cleared some of the low-hanging fruit away.

Hi Ed.

I'm still at this address. Unfortunately
I don't have much (any really) time to work
on netCDF now However, if I did, here are the things
I would probably look at.

  1. My current implementation really needs to
    be refactored to reduce some of the (in hindsight)
    extraneous code I implemented (almost 13 years ago
    now) when the F2003 C-Interop facility was still
    in its infancy. An example is the two modules that
    contain the C interop interfaces (module netdcd_nc_interfaces.f90
    and module_netcdf4_interfaces.f90) etc. In retrospect
    a better design option would have been to embed the interfaces
    in the routines that actually use them. This is what HDF5 does.
    This would allow you to get rid of those modules and not
    have to include their resulting .mod files in your include
    directories. My original decision to implement the interfaces
    this way reflected my coding practices back then. My thinking
    was that this approach mimicked the equivalent C header files.
    Removing then would eliminate the need for users to make sure
    they had the correct paths to the NetCDF include directories
    in their build scripts.

  2. The most recent edition of the Fortran standard (Fortran 2018
    released in December) defines a lot of enhancements to the C-interop
    facility that offers the promise of greatly reducing the amount
    of code you currently have to support all the multiple data types
    and precisions along with the current preprocessor code you
    have to support all the array ranks. In particular, three new facilities
    for passing arrays of any type, any rank as well as support for
    assumed shape Fortran dummy arguments which are passed as structures
    that contain more than just the address in memory ( ie. bound,
    rank, and kind information) so they are not directly interoperable
    with C. See the discussion of assumed type, assumed rank, and the
    C descriptors (supplied by a mandated C header file named
    ISO_Fortran_binding.h) in the attached PDF. Unfortunately,
    only the most recent versions of the Intel compiler (18 and 19)
    and probably the Cray compiler have full support for the new
    2018 features. gcc/gfortran has them implemented in their
    current development trunk (9.0) BUT I don't have any hope
    they will actually be usable (bug free) for a couple more
    years. The new version of the flang/LLVM compiler front end being
    developed by nVidia (called f18) will support them but it will
    probably be the end of the year before you can
    actually compile anything with it.

  3. I haven't kept up with any new functions you have in the
    C interfaces so I can't comment on the best way to support
    them. If I remember, the biggest missing capability in
    the Fortran interfaces was the ability to support arrays
    of strings (specifically arrays of variable length strings)
    That is doable with F2008/F2018 but is not directly supported
    by the standard Fortran 90 interfaces and probably
    can't be made backwards compatible to the Fortran 77
    interfaces so you would need to make sure users understood they would
    need a recent compiler to support them and make sure you had sufficient
    documentation on how to use them. Currently, the best
    way to implement arrays of variable length strings is to embed
    a F2003/2008 deferred length string in a derived type. I have
    a whole package of code I use to do this for other projects I
    can send you. The issue then becomes passing the derived type
    (structure) to C. An efficient implementation that makes
    thing as simple as possible for users will probably require
    some operator overloading for assignments etc and some
    new functions you would have to document.

Sorry I can't take a more active roll now (see
me in 2 or 3 years when I (hopefully)
retire). However, I will try to answer any Fortran programming
or implementation questions you have.

RW

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions