improper fortran casting
Wei-keng Liao
wkliao at ece.northwestern.edu
Mon Mar 9 17:16:09 CDT 2009
Hi, Rob,
This problem also happens in MPI-IO function
MPI_File_set_view(fh, disp, etype, filetype, datarep, info)
where disp must be an MPI_OFFSET kind in Fortran.
Your approach is what Rajeev suggested me a while ago.
I am sorry of not providing a solution here, but
eager to hear from Fortran experts.
Maybe from mpich community too.
Wei-keng
On Mar 9, 2009, at 3:05 PM, Robert Latham wrote:
> A question for the Fortran experts on this list:
>
> We have a C routine with this prototype:
>
> int ncmpi_put_att_int(int ncid, int varid, const char *name,
> nc_type type, MPI_Offset nelems, const int *value)
>
> (In this example, as would be by far the most common case, let's make
> MPI_Offset an 8 byte value)
>
> I run into problems when I call the fortran binding for the routine
> like this:
>
> integer ncid
> integer ierr
> integer n_elem
> ierr = nfmpi_put_att_int(ncid, NF_GLOBAL, 'my_attribute', NF_INT, 1,
> n_elem)
>
> The problem is that '1' there is treated as an array of MPI_Offset by
> the C function, but passed to pnetcdf's fortran binding as an array of
> integer (a 4 byte integer, at that). The C function recieves a
> 1-element array of MPI_Offset with contents of some enormous garbage
> number.
>
> If I define
>
> integer(KIND=MPI_OFFSET_KIND) one
>
> and pass that to nfmpi_put_att_int, then I have no problems.
>
> To make life as easy as possible for our Fortran users, how can I get
> Fortran to treat that constant '1' as an 8 byte value? In C, the
> compiler consults the prototype and promotes the type.
>
> Thanks
> ==rob
>
> --
> Rob Latham
> Mathematics and Computer Science Division A215 0178 EA2D B059 8CDF
> Argonne National Lab, IL USA B29D F333 664A 4280 315B
>
More information about the parallel-netcdf
mailing list