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

[netCDF #QYC-628947]: NF90_GET_VAR not working with user defined type variable



Hello,

I will try to answer as best I can; I am not a fortran programmer, however, but 
hopefully that won't matter.

1.  The input for NF90_GET_VAR is in fact the file ID number -or- the group ID 
number (when dealing with netCDF 4 files).
2. I'm glad you were able to get the information about compound files working.  
 If this were C code, you would use nc_get_var() to read the values of the 
compound variable type into an array of structs, which you would then inspect 
one at a time.  You could also use nc_get_var1() to read in a single element 
from the compound type data, but you would still have to inspect the components 
of the data type individually.  nc_get_var(), which is invoked by NF90_get_var, 
returns the entire compound variable in a struct, and does not provide direct 
access to the individual components.

I'm sorry I can't provide any information in a Fortran context; hopefully this 
information is useful.

-Ward

> 
> 
> Dear Ward
> 
> Your recommendation sounds good. However, the user
> guide is not clear about what is really required BEFORE using the
> function NF90_GET_VAR.
> 
> I can read and display every piece of
> information on my test nc file, incluing the cases when variables are
> compound user defined types with several fields, each field with a
> different type, inside a group, which may exist inside other groups. I
> am attaching a text file showing that I can extract information about
> every single variable of any type and dimension, on the root group (what
> I name level 1 group on my attached output file) or on other groups of
> level 2 or deeper.
> 
> The user guide does not explain HOW the information
> of compound user type, namely the information on the respective fields,
> should be made available to the funtion NF90_GET_VAR.
> 
> Indeed, the user
> guide says that the INPUT to that function is
> 
> (1) the file ID number
> (I suspect it should be the groupd ID number, not the file ID number...)
> 
> 
> (2) the variable ID number, as provided by a previous call to the
> function NF90_INQ_VARID, which requires as input the file ID (I suspect
> it should also be the group ID...) and the variable name
> 
> Thus I am
> somehow lost, because I do not know HOW the function NF90_GET_VAR has
> information about the names, types, sizes of the fields to be read.
> 
> It
> requires the variable ID only.
> 
> Shoud I work with the function
> NF90_GET_VAR for every single field each time, NOT to the whole compound
> type variable? If so, then the variable ID should be the field ID...
> 
> I
> would appreciate the kindness of your attention and help, particularly
> for clarification of the previous item,
> 
> Kind regards
> 
> Arlindo Arriaga
> 
> 
> PS: the variable I want to read has has the name "sst" and it is
> composed by two fields, each field is a real with 4 bytes.
> 
> Such a
> structure is allocated with the dimension 4320. I represent that
> variable in F90 as follows:
> 
> TYPE binDataType
> real(kind=4) :: sum
> 
> real(kind=4) :: sum_squared
> end type binDataType
> TYPE(binDataType),
> allocatable, dimension(:) :: sst_data
> 
> 
> +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
> 
> On
> Thu, 14 Apr 2016 10:20:38 -0600, Unidata netCDF Support wrote:
> 
> >
> Hello,
> >
> > In order to read data stored in a compound type, you must
> use `NF90_INQ_COMPOUND` to learn about the compound data structure. The
> user guide for netCDF-Fortran NF90 may be found here:
> >
> > *
> http://www.unidata.ucar.edu/software/netcdf/documentation/historic/netcdf-f90/Compound-Types.html#Compound-Types
> [1]I hope this helps,
> >
> > -Ward
> >
> >> Dear Lady or Sir I would
> appreciate if you could tell me how to read data from nc files with
> netCDF-4 format using F90. The Fortran library function NF90_GET_VAR
> works well with integer or real arrays, but it can not compile if I want
> to read a compound user defined type variable (as for example, sst on a
> MODIS nc file with netcdf-4 format). Please let me know what may your
> services suggest as an alternative to that F90 library function ? I
> thank you for the kindness of your attention. Kind regards Arlindo
> Arriaga, PhD Meteorology UW-Madison 1991
> >
> > Ticket Details
> >
> ===================
> > Ticket ID: QYC-628947
> > Department: Support
> netCDF
> > Priority: Normal
> > Status: Closed
> 
> 
> 
> Links:
> ------
> [1]
> http://www.unidata.ucar.edu/software/netcdf/documentation/historic/netcdf-f90/Compound-Types.html#Compound-Types
> 
> 


Ticket Details
===================
Ticket ID: QYC-628947
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.