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

[netCDF #IXE-857786]: C++ NetCDF Library Troubles



Hello,

I do not see any obvious issues with what you have written; let me take a look 
at the C++ interface and see if I can figure out what is going on.  I will 
follow up with you after I have some additional information.

-Ward

> Good afternoon,
> 
> I feel I am very close to implementing a functional c++ program to extract a 
> chunk of NetCDF data from the HYCOM/GOFS 3.1 Hindcast data.
> [http://tds.hycom.org/thredds/dodsC/GLBv0.08/expt_93.0.html 
> <http://tds.hycom.org/thredds/dodsC/GLBv0.08/expt_93.0.html>]
> 
> However, when I attempt to pass an array (of type float, or double, say) by 
> reference to getVar(), the temperature and salinity values  are not being 
> written to the array.
> 
> I believe I have sized/pre-allocated the array correctly, and am using the 
> startp and countp vectors correctly; I do not know what is going wrong.  This 
> is a typical output of my program:
> -----------------------
> NETCDF FILE INFO:
> 14 variables
> 10 attributes
> 4 dimensions
> 0 groups
> 0 types
> 
> -----------------------
> VARIABLES:
> depth
> lat
> lon
> salinity
> salinity_bottom
> surf_el
> tau
> time
> water_temp
> water_temp_bottom
> water_u
> water_u_bottom
> water_v
> water_v_bottom
> 
> -----------------------
> DIMENSIONS:
> depth
> lat
> lon
> time
> 
> -----------------------
> DIMENSION SIZES:
> depth = [0:5000]        [n=40]
> lat   = [-80:90]        [n=3251]
> lon   = [0:359.92]      [n=4500]
> time  = [157812:161409] [n=1168]
> 
> -----------------------
> SPATIAL RANGE:
> Requested:
> LAT = [0:2]
> LON = [154:155]
> Actual:
> LAT[1500:1525] = [0:2]
> LON[1925:1938] = [154:155.04]
> 
> startp[0] = 1167
> countp[0] = 1
> startp[1] = 0
> countp[1] = 40
> startp[2] = 1500
> countp[2] = 26
> startp[3] = 1925
> countp[3] = 14
> 
> --------------------------------
> ARRAYS CREATED:
> SALT[40][26][14]
> TEMP[40][26][14]
> 
> -----------------------
> SALT[31][3][6] = 161409 psu
> SALT[33][0][1] = 1.76622e+264 psu
> SALT[33][9][0] = 1.76622e+264 psu
> SALT[33][13][12] = 1.76622e+264 psu
> SALT[33][17][6] = 1.76622e+264 psu
> SALT[33][20][8] = 9.75388e+199 psu
> SALT[33][20][9] = 7.62831e+228 psu
> SALT[33][20][10] = 7.96474e+175 psu
> SALT[33][20][12] = 5.13122e+252 psu
> SALT[33][21][10] = 1.76622e+264 psu
> SALT[34][6][2] = 1.76622e+264 psu
> SALT[34][6][10] = 1.76622e+264 psu
> SALT[34][8][12] = 359.92 psu
> SALT[37][2][8] = 1.76622e+264 psu
> SALT[37][11][8] = 1.76622e+264 psu
> SALT[37][12][2] = 1.76622e+264 psu
> SALT[39][3][11] = 155.04 psu
> SALT[39][4][12] = 155.04 psu
> SALT[39][5][13] = 155.04 psu
> SALT[39][7][0] = 155.04 psu
> SALT[39][16][2] = 1.76622e+264 psu
> SALT[39][23][8] = 1.76622e+264 psu
> SALT[39][24][8] = 1.76622e+264 psu
> *** SUCCESS! ***
> 
> 
> where the first index refers to depth, the second to latitude, and the third 
> to longitude.
> 
> Are there any obvious “gotchas” that new NetCDF users typically get wrong?
> I will attach my current code for reference.  Thank you in advance for any 
> help you are able to give!
> 
> Cheers,
> 
> Blake Cole
> Phd Student
> Mechanical Engineering Dep’t, MIT
> 
> 
> 
> 


Ticket Details
===================
Ticket ID: IXE-857786
Department: Support netCDF
Priority: Normal
Status: Closed
===================
NOTE: All email exchanges with Unidata User Support are recorded in the Unidata 
inquiry tracking system and then made publicly available through the web.  If 
you do not want to have your interactions made available in this way, you must 
let us know in each email you send to us.