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

[netCDF #ZPG-755636]: Reading and extracting WRF time characters using C++ interface

Hi Scott,

> Email Address: address@hidden
> Organization: UCLA
> Package Version:
> Operating System: Linux
> I am trying to read in a Time variable (character) output by WRF using
> the C++/netCDF interface.  What is the proper way to do this?
> This works:
> char timein[NTIM][19];
> if (!timVar->get(&timein[0][0], NTIM))
> return NC_ERR;
> Then, I simply want to extract the year, mo, day and hour into separate
> integer or string variables.  How can I do this?
> Here is the ncdump -h output:
> dimensions:
> Time = UNLIMITED ; // (48 currently)
> DateStrLen = 19 ;
> west_east = 195 ;
> south_north = 126 ;
> variables:
> char Times(Time, DateStrLen) ;
> and, some examples:
> Time[0] DateStrLen[0] Times[0--18]='2012-12-01_12:00:00'
> Time[1] DateStrLen[0] Times[19--37]='2012-12-01_13:00:00'
> Time[2] DateStrLen[0] Times[38--56]='2012-12-01_14:00:00'
> Time[3] DateStrLen[0] Times[57--75]='2012-12-01_15:00:00'
> Time[4] DateStrLen[0] Times[76--94]='2012-12-01_16:00:00'

Sorry, the netCDF library doesn't have any general string-parsing functions.
These date-time strings are all fixed length, so I would think you could
do what you want by just indexing into the string and using a library
function such as strncpy() from the C libraries or whatever the equivalent
is for C++.


Russ Rew                                         UCAR Unidata Program
address@hidden                      http://www.unidata.ucar.edu

Ticket Details
Ticket ID: ZPG-755636
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.