[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: 20000303: Bug in F90 nf90_get_var



Russ (and Robert),

Further to my message below I have found out why my application is failing
on nf90_get_var_text() (even with the correction pointed out previously).

My application calls nf90_get_var() to read a character*60 string from a
valid netcdf file. I know the file is ok because if I switch the call to
nf_get_var_text() it works fine. My application hangs on this call. In fact
it's spinning the CPU to 100% and I know why now.

Inside the function nf90_get_var_text() there is a "do ... end do"
construct. The only way of breaking from this perpetual loop is 2 'exit'
statements which are triggered when either nf90_inquire_dimension() or
nf90_inquire_variable() return an error. Clearly if the variable is present
and correct these will NEVER fail and the loop will keep going forever. The
code would work if the 'do .. end do' was not present but it may be there
for a reason (although I can't see it at the moment).

I'm also slightly puzzled that the arg list is different to the
documentation and what the localIndex variable is doing but I've not worked
my way completely through the code and .m4 files yet.

Hope this helps.

Regards,
          Glenn


At 8:33 pm +0100 3/4/00, Russ Rew wrote:
>>To: address@hidden
>>cc: address@hidden
>>From: Glenn Carver <address@hidden>
>>Subject: Bug in F90 nf90_get_var
>>Organization: Centre for Atmospheric Science, Chemistry Dept., Cambridge
>>University, UK
>>Keywords: 200004031612.KAA13956
>
>Hi Glenn,
>
>> I believe I have found a bug in the f90 API for netcdf.
>>
>> There is a bug in netcdf_text_variables.f90 where the function
>> nf90_get_var_text() mistakenly calls nf_PUT_vars_text() instead of
>> nf_GET_vars_text().
>>
>> I append the context diff below.
>>
>> I say, I *believe* this is a bug because at the moment, even with this
>> correction I am still unable to use the nf90_get_var() call to read a
>> character string, the program is still hanging. I'll keep investigating but
>> any feedback would be useful.
>
>Yes, it looks like a bug to me too.  Thanks for reporting this.
>
>[Robert, I can fix this and make a new tar file available, if you agree
> on the fix (changing "nf_put_vars_text" to "nf_get_vars_text" in line
> 38 of netcdf_text_variables.f90).]
>
>> Thanks for making the f90 API available. I was going to do one myself and
>> it saved me a lot of work!!
>>
>> One other quick point. On the install instructions for the f90 interface
>> there is one final step missing. The netcdf.o produced can either be added
>> to the libnetcdf.a file or added explicitly to the users compilation.
>> Either way, this step is not mentioned, although the use of the .mod file
>> is.
>
>I've added a final step to the install instructions.  We're finally
>starting the work needed to integrate the f90 interface into the
>netCDF 3.5 distribution, which will fix this by making the install
>work just as it does for f77, via configure and Makefiles, so the user
>won't have to do anything extra to get the f90 interface if a Fortran
>90 compiler is available.
>
>> Cheers,
>>           Glenn
>
>> --
>> % diff -c netcdf_text_variables.f90 netcdf_text_variables.f90.old
>> *** netcdf_text_variables.f90   Mon Apr  3 15:52:40 2000
>> --- netcdf_text_variables.f90.old       Mon Apr  3 15:51:18 2000
>> ***************
>> *** 35,41 ****
>>          if(nf90_get_var_text /= nf90_noerr) exit
>>          ! How many characters to ask for? The smaller of the space
>>provided by
>> the caller
>>          !   or the line length in the netCDF file.
>> !        nf90_get_var_text = nf_get_vars_text(ncid, varid, 1,
>>min(stringLength,
>> len(values)), 1, values)
>>        end do
>>      end function nf90_get_var_text
>
>> --- 35,41 ----
>>          if(nf90_get_var_text /= nf90_noerr) exit
>>          ! How many characters to ask for? The smaller of the space
>>provided by
>> the caller
>>          !   or the line length in the netCDF file.
>> !        nf90_get_var_text = nf_put_vars_text(ncid, varid, 1,
>>min(stringLength,
>> len(values)), 1, values)
>>        end do
>>      end function nf90_get_var_text



--
Dr. Glenn Carver, Senior Research Associate,
Centre for Atmospheric Science, Chemistry Dept., Cambridge University, UK
mailto:address@hidden   http://www.atm.ch.cam.ac.uk/~glenn/

              "I never think of the future, it comes soon enough"
                   - Albert Einstein