In a declaration:<br>integer(kind=MPI_OFFSET), parameter :: one = 1<br><br>or inline:<br>int(1,kind=MPI_OFFSET)<br><br><div class="gmail_quote">On Mon, Mar 9, 2009 at 2:05 PM, Robert Latham <span dir="ltr"><<a href="mailto:robl@mcs.anl.gov">robl@mcs.anl.gov</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">A question for the Fortran experts on this list:<br>
<br>
We have a C routine with this prototype:<br>
<br>
int ncmpi_put_att_int(int ncid, int varid, const char *name,<br>
nc_type type, MPI_Offset nelems, const int *value)<br>
<br>
(In this example, as would be by far the most common case, let's make<br>
MPI_Offset an 8 byte value)<br>
<br>
I run into problems when I call the fortran binding for the routine<br>
like this:<br>
<br>
integer ncid<br>
integer ierr<br>
integer n_elem<br>
ierr = nfmpi_put_att_int(ncid, NF_GLOBAL, 'my_attribute', NF_INT, 1, n_elem)<br>
<br>
The problem is that '1' there is treated as an array of MPI_Offset by<br>
the C function, but passed to pnetcdf's fortran binding as an array of<br>
integer (a 4 byte integer, at that). The C function recieves a<br>
1-element array of MPI_Offset with contents of some enormous garbage<br>
number.<br>
<br>
If I define<br>
<br>
integer(KIND=MPI_OFFSET_KIND) one<br>
<br>
and pass that to nfmpi_put_att_int, then I have no problems.<br>
<br>
To make life as easy as possible for our Fortran users, how can I get<br>
Fortran to treat that constant '1' as an 8 byte value? In C, the<br>
compiler consults the prototype and promotes the type.<br>
<br>
Thanks<br>
==rob<br>
<font color="#888888"><br>
--<br>
Rob Latham<br>
Mathematics and Computer Science Division A215 0178 EA2D B059 8CDF<br>
Argonne National Lab, IL USA B29D F333 664A 4280 315B<br>
</font></blockquote></div><br>