> ncdigest Thursday, 5 October 1995 Volume 01 : Number 290
>
> From: Arlindo da Silva <dasilva@xxxxxxxxxxxxxxxxxx>
> Date: Thu, 5 Oct 1995 13:37:05 -0400 (EDT)
> Subject: Portability question
>
> I have a question regarding the portability of FORTRAN application programs
> which rely on netcdf. Suppose I have a CDL which defines a given
> variable as SHORT, say
>
> .....................
> variables:
>
> short var[dim]
>
> .....................
>
> Now, on my SGI I use 'ncgen' to create the corresponding FORTRAN code
> and get
>
> integer*2 var(1)
>
> which makes sense since the NC_SHORT data type takes 2 bytes. Now,
> when I use 'ncgen' on the Cray C90 under unicos, I get the following:
>
> integer var(1)
>
> My problem is that I'd like to have the same FORTRAN code to work on
> both Cray and workstation. It appears that I'd have to have different
> FORTRAN codes for each hardware, which somewhat defeats one of the
> purposes of netCDF: portability.
>
> My questions:
>
> 1. Am I missing something?
> 2. Is there any way around short of using #IFDEFS?
Yes to both questions. I hope the following helps. I was confused at first
too.
First note that the size (number of bits) in memory used by netCDF software
can be (e.g. for Cray) different from that in the netCDF file.
char byte short long float double
netCDF file 8 8 16 32 32 64
SGI memory 8 8 16 32 32 64
Cray memory 8 8 64 64 64 64
Other 32-bit workstations (e.g. Sun Sparc) should be the same as the SGI.
INTEGER*2 is treated as INTEGER on Cray, so version ncgen'd on SGI will work
on Cray. However INTEGER*2 is non-standard, so it may well be rejected by
some compilers.
The only type on Cray which you need to be careful with is double.
Compile with following to give 64 (rather than 128) bit DOUBLE PRECISION.
cf77 -Wf"-dp
Harvey Davies, Home: +61 3 9772 5199
CSIRO Division of Atmospheric Research, Work: +61 3 9586 7574
Private Bag No. 1, Mordialloc, Fax: +61 3 9586 7600
Victoria 3195, Australia E-mail: hld@xxxxxxxxxxxx