[netcdfgroup] Trouble with Fortran90 NetCDF: Output Variables Have Wrong Order of Dimensions

Classification: UNCLASSIFIED
======================================================

 

Hello all,

 

This is my first time writing in; I appreciate any advice I receive, and I
thank you in advance.

 

I have been using the Fortran 90 NetCDF module to convert a considerably
large dataset (21600 × 43200 elements of latitude × longitude) into NetCDF
format, and I inevitably encounter the same problem upon output: my data
variables are dimensioned as Var(Lon, Lat) instead of Var(Lat, Lon).

 

After I fill my latitude & longitude arrays with the appropriate values, I
execute the following code (I use cmod = NF90_64BIT_OFFSET because the file
size exceeds 2 GB): 

call NF90_CREATE(FILE_NAME, cmod = NF90_64BIT_OFFSET, ncid = ncid)

call NF90_DEF_DIM(ncid, ?Lat?, 21600, lat_dimid) 

call NF90_DEF_DIM(ncid, ?Lon?, 43200, lon_dimid)

dimids = (/ lat_dimid, lon_dimid /)            ! Print statements always
show that this is equal to (1, 2)

 

! I define the coordinates as double precision floats, but the data variable
is single precision

call NF90_DEF_VAR(ncid, ?Lat?, NF90_DOUBLE, lat_dimid, lat_varid)

call NF90_DEF_VAR(ncid, ?Lon?, NF90_DOUBLE, lon_dimid, lon_varid)

call NF90_DEF_VAR(ncid, ?Var?, NF90_REAL, dimids=dimids, var_varid)

 

After the above definitions, I assign units, names, etc., to the variables,
ALWAYS defining the latitude first, followed by the longitude, and the
?dimids? array is always (1, 2) corresponding to (lat, lon).

 

After exiting definition mode, I call NF90_PUT_VAR for latitude first, then
longitude, with print statements confirming that lat_varid = 1 & lon_varid =
2. 

 

Then, I run

call NF90_PUT_VAR(ncid = ncid, varid = var_varid, values = var_out, start =
(/ 1, 1 /), count = (/ 21600, 43200 /))

 

When I call ncdump -h to view the metadata of the output file, the variable
is ALWAYS of dimension (Lon, Lat) despite the above code, and I need it to
be in (Lat, Lon). 

 

Please note that because the file is excessively large (the .nc file is 3.5
GB), I cannot simply modify the CDL text and call ncgen to re-create the
NetCDF file. Additionally, I do not have access to the CDO operators and
cannot install them. Therefore, my only possible method (at least, to my
knowledge) is via Fortran.

 

Thank you!

 

Best Regards,

Cory Reed, PhD
Geodetic Earth Scientist

National Geospatial-Intelligence Agency

Geodesy/Geophysics II (SFNAF)

Office of Geomatics

Unclass: (571) 558-5379

Mobile: (314) 608-9269

 

======================================================
Classification: UNCLASSIFIED

 

Attachment: smime.p7s
Description: S/MIME cryptographic signature

  • 2024 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdfgroup archives: