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

[netCDF #GKA-285302]: netCDF General - nc_get_var_type or nc_get_varm_type



> Institution: University of Massachusetts
> Package Version: 3.6
> Operating System: Linux
> Hardware Information: Pentium IV, 4GB ram
> Inquiry: Dear Sir/Madam,
> 
> I would like to read the 2D variable from NetCDF file into memory structure. 
> I don\\\'t have a problem reading it into contiguous array; however, when I 
> use nc_get_var_float where my internal memory array is predefined as a single 
> variable array; however, when I try to read it into a structure nc_get 
> doesn\\\'t respect the structure; it rather reads the data continuously into 
> memory. I tried to use the nc_get_varm_type; however, I don\\\'t understand 
> how to use the \\\"imap\\\" entry correctly and I am not even sure if it is 
> possible to map the data into structured array. Attached files are: 
> executable \\\"NetCDF_In_2\\\"; source code \\\"NetCDF_In_2.c\\\" and NetCDF 
> data file \\\"work.nc\\\". Array \\\"Temporary\\\" works fine; working with 
> my structure SPH_STRUCT with \\\"NetCDF_out.Refl\\\" doesn\\\'t get the 
> variables correctly. I understand that I could read all the variables into 
> temporary array and then transfer it to my structure; however, I plan to use 
> this file i!
 n !
> real time envirnment where the process speed is very important. Thank you 
> very much.
> Edin Insanic
> P.S. For some reason I couldn't upload my NetCDF data file (~7MB). If you 
> need it, I can provide it for you online.
> 
> 
> 

Howdy Edin!

I don't believe there is a way to do what you want. How can netCDF know how to 
unpack the data into your structs? It does not have any knowledge of the 
structs.

Perhaps you should be looking at nc_get_vara_float, which will allow you to 
read a subset of your array. Perhaps you could call with with the data pointer 
for your struct, and then read in one struct worth of data at a time.

You probably don't want to be messing with the varm functions. I don't think 
they will help you at all.

Please let me know how this works out for you.

Thanks!

Ed

Ticket Details
===================
Ticket ID: GKA-285302
Department: Support netCDF
Priority: Normal
Status: Closed