PnetCDF Fortran Binding Issues

Jianwei Li jianwei at cheetah.cpdc.ece.nwu.edu
Thu Aug 7 13:06:16 CDT 2003



On Thu, 7 Aug 2003, Jianwei Li wrote:

>
> Bill,
>
> I've identified those functions & arguments that need such F-C conversion
> in the attached txt file. They are C functions that the Fortran binding
> functions are calling, and F-C conversion should be done before calling
> the C interface functions.
	Sorry, there was a mistake.
	For INPUT arguments, the F-C conversion should be done before
	calling the C interface functions; but for OUTPUT arguments,
	that should be done afterward.

	Jianwei
>
> I have following assumptions:
> 1. Fortran interface requires users to define their multi-dimension arrays
>    in a reverse numerical dimension order than their target netCDF array
>    variables (which are stored in row-major/C order);
> 2. Fortran users specify 1-based indices for array element coordinates
>    when they call those data access functions;
> 3. Dimension ID follows 0-based convention, as all other internal IDs do.
>
> Assumption 1&2 are specified in Original netCDF Fortran Interface user
> guide and confirmed in the src code.
> Assumption 3, however, is not confirmed in the original netCDF src code;
> instead, the original one seems to try putting it 1-based. But I don't
> find any reason to do that way, since all other internal IDs (ncid,
> varid, attrid, ...) are 0-based, and as long as they are for internal
> references, they can be kept 0-based, which will save a lot of function
> modifications. And, what's strange is that I didn't find any code
> converting between 0-based and 1-based dimids in the original netCDF,
> except in the definition/inquiry of dimension list for the array varible.
> If they didn't take care of it for other single dimention definitions
> and inquiries, that'll be a big bug in their code //Yet I didn't find
> anyone report such a failure... hmm, maybe they hid it some where else?
>
> Anyway, we should try solve the F-C conversion problem in one way and
> test it.
>
> Jianwei
>
> On Wed, 6 Aug 2003, William Gropp wrote:
>
> > At 01:21 PM 8/4/2003 -0500, Jianwei Li wrote:
> >
> > >Bill,
> > >
> > >I took a look at the original netCDF library User Guide and the src code,
> > >The index in C interface is 0-based and that in Fortran is 1-based.
> > >
> > >There is functions converting FORTRAN co-ordinates into C co-ordinates.
> > >
> > >     for (i = 0; i < ndims; ++i)
> > >         ccoords[i] = fcoords[ndims - 1 - i] - 1;
> > >
> > >The dimension-ID vector, count, stride are also converted in such a way.
> > >So, now I'm sure the original netCDF requires that Fortran users define
> > >their array variables in a reverse dimension order than if C code is used.
> > >In users' view, if we talk about most/least significant dimension instead
> > >of the numerical order, Fortran interface and C interface look common.
> > >Within the Fortran binding, however, it reverses all dimension-related
> > >index vectors before calling the C functions, and it also converts between
> > >0-based and 1-based indices.
> > >That way, the data buffer of the array variables don't need to be
> > >transposed in the Fortran binding implementation.
> > >
> > >So, I think, all we need to do in the Fortran binding is to implement the
> > >same index vector convertion for those involved functions --- convert
> > >from F to C for input index vectors, and from C to F for output ones.
> > >
> > >I can list those function and their victim arguments, if that helps.
> >
> > That would be a big help.  This might also change the size_t handling.
> >
> > Bill
> >
>




More information about the parallel-netcdf mailing list