This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
>To: address@hidden >cc: Robert Pincus <address@hidden> >From: Martin Dix <address@hidden> >Subject: Problems with integer kinds and the netcdf f90 interface >Organization: . >Keywords: 200003210138.SAA07711 Hi Martin, > I've had more problems with integer kinds on both a Cray J90 and NEC > SX-4. > The typeSizes module defines > integer, parameter :: OneByteInt = selected_int_kind(2), & > TwoByteInt = selected_int_kind(4), & > FourByteInt = selected_int_kind(9), & > EightByteInt = selected_int_kind(18) > though only the 1, 2, and 4 byte ints are used in overloaded > functions. > On the Cray, all these kinds are available, but the default integer > type is 8 bytes so there isn't an appropriate overloaded function. > On the SX-4 things are even more complicated. In its 32 bit mode the > integer kinds are > Kind Range > 2 4 > 4 9 > 8 15 > Note that the kind 8 range is only 15. It uses 53 bits (just the FP > mantissa) rather than 64. > In practice we most often use a compiler option that sets all the > defaults to 64 bits. In this case there is only a single integer kind. > There is a version of the netcdf library that works with this. I'm not > sure what sort of tricks the C compiler does but it all works properly > (at least when just using integers aand reals from fortran). > I really like the new interface and would be disappointed if it > couldn't be supported everywhere. In my own work I just use default > integers and reals in programs and let the library take care of the > conversion to the appropriate types in the netcdf file. > As an experiment, I modified the netcdf interface to use only a > single integer kind, removing all the overloading on type. This works > properly on both machines. Perhaps there could be a "minimal" > interface like this as well as the full one for the machines that > support all the types. The alternative would seem to be some pretty > tricky preprocessing (though given what's already been done with m4 to > do the overloading, you might find it rather easier than me). Thanks for the suggestion and letting us know about the problems on the J90 and SX-4. Currently this interface is supported on a volunteer basis. It is intended to work without modification using ANSI compliant compilers that provide the netCDF data types (one, two, and four byte integers; four and eight byte reals). We hope to extend the support to other platforms as time allows. I'm filing this reply in our netCDF support database (unless you let me know that you would prefer to remain anonymous), to make information about your single integer kind version available to others. Alternatively, if you'd like to make it available here as contributed software, we could take you out of the loop. The m4 stuff was a bootstrap to help generate lots of versions from the original pattern Robert Pincus supplied, but some of these generated versions were subsequently refined, so at this point I'm not sure the m4 macros are still useful ... --Russ _____________________________________________________________________ Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu