<div dir="ltr"><div><div><div><div>Dear Wei-Keng,<div><br></div>Thanks to your suggestions I was finally able to understand what's causing the issue.<br><br></div>I asked the model to print out the subtitle (one of the golbal attributes) of the netcdf file that's being passed to nfmpi and, in fact, it seems that the model is passing the wrong file to the function. <br><br></div>I didn't catch this issue before because if I simply renamed (or removed) the correct file, the model broke with a consistent error (i.e.: stating that the correct file was not there) and I therefore assumed that the correct id was passed to the function.<br><br></div>It is, therefore, NOT a pnetcdf issue, but something within the model. <br><br>Thank you for your efficient and clear support and Best Regards,<br><br></div>Federico Carotenuto<br><div><br><br></div></div><div class="gmail_extra"><br><div class="gmail_quote">2017-05-26 19:10 GMT+02:00 Wei-keng Liao <span dir="ltr"><<a href="mailto:wkliao@eecs.northwestern.edu" target="_blank">wkliao@eecs.northwestern.edu</a>></span>:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi, Federico<br>
<br>
Your code fragment looks fine with me. Based on your description,<br>
the value of lengttt2 should be 3.<br>
<br>
Please run command "ncdump -h <a href="http://file.nc" rel="noreferrer" target="_blank">file.nc</a>" or "ncmpidump -h <a href="http://file.nc" rel="noreferrer" target="_blank">file.nc</a>"<br>
which show the file header that include the current value of the<br>
unlimited dimension, "time". Its value should be 3.<br>
<br>
Please also check whether the same file is used by the ncdump command<br>
and your Fortran program.<br>
<br>
If the above are all checked out file, could you provide a shorten program<br>
that can reproduce the error, so I can take a look?<br>
<span class="HOEnZb"><font color="#888888"><br>
Wei-keng<br>
</font></span><div class="HOEnZb"><div class="h5"><br>
On May 26, 2017, at 9:34 AM, Federico Carotenuto wrote:<br>
<br>
> Dear Wei-keng,<br>
><br>
> Thanks to your suggestion I was able to work around the issue, just to be faced with a different error about "Index exceeds dimension bound".<br>
><br>
> My code now looks like this:<br>
><br>
> ncstat = nfmpi_inq_varid(emisa_nc%id, 'Times', emisa_times_varid); NCERR(__LINE__)<br>
> ncstat = nfmpi_inq_vardimid(emisa_nc%<wbr>id,emisa_times_varid,dimidz); NCERR(__LINE__)<br>
> write(*,*) "EMISA_TIMES HAS DIMID(1) = ",dimidz(1)<br>
> write(*,*) "EMISA TIMES HAS DIMID(2) = ",dimidz(2)<br>
> ncstat = nfmpi_inq_dim(emisa_nc%id,<wbr>dimidz(1),dimchar1,lengttt1); NCERR(__LINE__)<br>
> ncstat = nfmpi_inq_dim(emisa_nc%id,<wbr>dimidz(2),dimchar2,lengttt2); NCERR(__LINE__)<br>
> write(*,*) "DIMID(1) LENGTH = ",lengttt1<br>
> write(*,*) "DIMID(1) NAME   = ",dimchar1<br>
> write(*,*) "DIMID(2) LENGTH = ",lengttt2<br>
> write(*,*) "DIMID(2) NAME = ",dimchar2<br>
> ncstat = nfmpi_get_vara_text_all(emisa_<wbr>nc%id, emisa_times_varid, &<br>
>  &   (/i2offset(1), i2offset(ihourrun+1)/), (/i2offset(dlen), i2offset(1)/), datebuf)<br>
> NCERR(__LINE__)<br>
><br>
> It appears that the correct varable id for "Times" was actually 4 from the Fortran point of view. "Times" have two dimensions: 1 to store the  time itself in format "YYYY/MM/DD hh:mm:ss" (total length 19 characters), and 2 is the unlimited dimension time.<br>
><br>
> Now while dimension one with name "DateStrLen" has a correct length of 19, the time dimension has apparently a length of 0, thus generating the aforementioned error.<br>
> By checking on the file with other tools that dimension is unlimited but should have length 3 in the file.<br>
><br>
><br>
><br>
><br>
><br>
><br>
> 2017-05-26 14:14 GMT+02:00 Federico Carotenuto <<a href="mailto:carotenuto.federico@gmail.com">carotenuto.federico@gmail.com</a><wbr>>:<br>
> Dear Wei-keng,<br>
><br>
> Thank you for your quick reply! Sorry if I'm replying via email but I can't find an option to reply to the ticket directly.<br>
><br>
> I followed your suggestion and modified the source code in the following way, in order to echo the value of emisa_times_varid before NCERR<br>
><br>
> write(*,*) "EMISA_TIMES_VARID =",emisa_times_varid<br>
> ncstat = nfmpi_get_vara_text_all(emisa_<br>
> nc%id, emisa_times_varid, &<br>
>          &   (/i2offset(1), i2offset(ihourrun+1)/), (/i2offset(dlen), i2offset(1)/), datebuf)<br>
> write(*,*) "EMISA_TIMES_VARID AFTER =",emisa_times_varid<br>
>           NCERR(__LINE__)<br>
><br>
><br>
> In both cases, before and after the call to nfmpi, the value of emisa_times_varid is 0.<br>
><br>
> As your links states that is effectively the NC_GLOBAL constant for Fortran.<br>
><br>
><br>
><br>
><br>
> 2017-05-25 18:46 GMT+02:00 parallel-netcdf <<a href="mailto:parallel-netcdf@mcs.anl.gov">parallel-netcdf@mcs.anl.gov</a>>:<br>
> #30: Action prohibited on NC_GLOBAL varid<br>
> ------------------------------<wbr>------------------------------<wbr>-----+----------<br>
>  Reporter:  Federico Carotenuto <carotenuto.federico@…>          |       Owner:  wkliao<br>
>      Type:  defect/bug                                           |      Status:  assigned<br>
>  Priority:  major                                                |   Milestone:<br>
> Component:  parallel-netcdf                                      |     Version:  1.8.1<br>
>  Keywords:                                                       |<br>
> ------------------------------<wbr>------------------------------<wbr>-----+----------<br>
> Changes (by wkliao):<br>
><br>
>   * owner:  robl => wkliao<br>
>   * status:  new => assigned<br>
><br>
><br>
> Comment:<br>
><br>
>  Hi,<br>
><br>
>  The Fortran constant NF_GLOBAL is defined in both NetCDF and PnetCDF as<br>
>  value 0.<br>
>  Its corresponding constant in C library NC_GLOBAL is defined as value -1.<br>
>  The variable ID returned from the Fortran nfmpi_def_var API should have a<br>
>  value larger than 0.<br>
>  You might want to check the value of emisa_times_varid right after the<br>
>  call to nfmpi_def_var.<br>
>  Do let me know if you got 0 for emisa_times_varid.<br>
><br>
>  The MATLAB may return a value that is C based.<br>
><br>
>  See definition of nf_global in the NetCDF Fortran header file from this<br>
>  URL[[br]]<br>
>  <a href="https://github.com/Unidata/netcdf-" rel="noreferrer" target="_blank">https://github.com/Unidata/<wbr>netcdf-</a><br>
>  fortran/blob/master/fortran/<wbr>netcdf3.inc#L96<br>
><br>
>  and PnetCDF Fortran header files from[[br]]<br>
>  <a href="https://trac.mcs.anl.gov/projects/parallel-" rel="noreferrer" target="_blank">https://trac.mcs.anl.gov/<wbr>projects/parallel-</a><br>
>  netcdf/browser/trunk/src/libf/<a href="http://pnetcdf.inc.in#L161" rel="noreferrer" target="_blank"><wbr>pnetcdf.inc.in#L161</a><br>
><br>
>  Wei-keng<br>
><br>
> --<br>
> Ticket URL: <<a href="http://trac.mcs.anl.gov/projects/parallel-netcdf/ticket/30#comment:1" rel="noreferrer" target="_blank">http://trac.mcs.anl.gov/<wbr>projects/parallel-netcdf/<wbr>ticket/30#comment:1</a>><br>
> parallel-netcdf <<a href="https://trac.mcs.anl.gov/projects/parallel-netcdf" rel="noreferrer" target="_blank">https://trac.mcs.anl.gov/<wbr>projects/parallel-netcdf</a>><br>
><br>
><br>
><br>
<br>
</div></div></blockquote></div><br></div>