netcdf-fortran icon indicating copy to clipboard operation
netcdf-fortran copied to clipboard

API bug in cache_preemption

Open WardF opened this issue 9 years ago • 3 comments

This issue was reported originally to the netcdfgroup mailing list by Ed Zaron.

Hi Netcdf developers,

I am working my way through a reimplementation of the f90 API and noticed a minor bug in nf90_create or its documentation.

The documentation states that cache_preemption is of type real: https://www.unidata.ucar.edu/software/netcdf/docs/netcdf-f90/NF90_005fCREATE.html#NF90_005fCREATE

In contrast, the module definition expects type integer. I cannot seem to find the nf90 source at the Unidata web site, but browsing the netcdf.mod file seems to indicate that some routines expect cache_preemption to be real and others expect it to be integer.

I am using netcdf 4.1.3 installed in an ubuntu 14.04.

WardF avatar Dec 01 '15 17:12 WardF

The cache preeption is a float in the C library.

It is an integer in the Fortran library ((int)(cache_preemtion * 100)).

This was to avoid passing a float to fortran in olden times, when integers were easier, before the Fortran 2003 C API layer was commonplace.

So if it is called a float in any fortran documentation, that is a bug. The link you posted is broken. @WardF where is the fortran documentation on the web these days?

edhartnett avatar Jan 08 '18 23:01 edhartnett

The fortran documentation currently used is the historic Fortran documentation, and resides in https://www.unidata.ucar.edu/software/netcdf/documentation/historic/netcdf/index.html

WardF avatar Jan 10 '18 19:01 WardF

I was about to file an issue about this as I was reading about and experimenting with cache_preemption (see #206) and based my test on f90tst_parallel3.F90. (As we are trying to find a memory leak we are pretty sure is in netCDF somewhere.)

My compiler failed out because a real is expected by nf90_open (as the docs say), and I was passing an integer. Conversely, nf90_create expects an integer but the docs say it's real.

A further ripgrep shows that netcdf4_func.f90 has cache_preemption as a real, while netcdf4_variables.f90 has it as integer. I thought about filing a pull request but as I'm not sure what should be the right interface, I thought I'd comment here to keep track.

mathomp4 avatar Nov 25 '19 20:11 mathomp4