This archive contains answers to questions sent to Unidata support through mid-2025. Note that the archive is no longer being updated. We provide the archive for reference; many of the answers presented here remain technically correct, even if somewhat outdated. For the most up-to-date information on the use of NSF Unidata software and data services, please consult the Software Documentation first.
>To: address@hidden >From: address@hidden (Jim Hines (awdnsun) 472-6708) >Subject: netcdf/udunits >Organization: . >Keywords: 199610151305.AA28322 Jim, > >> When I do > >> call ncagtc(ncid,NCGLOBAL,'_basetime',basetime,80,rcode) > >> utdec(basetime,t_unit) > >> uticaltime(1948,8,1,0,0,0,t_unit,ref_val) > >> > >> ref_val=0.0 > >> > >> and when I do a > >> uticaltime(1948,8,1,24,0,0,t_unit,ref_val) > >> ref_val=1.0 > > > >Those both seem correct, since the first specifies 0.0 days since > >1948-08-01 00:00, and the second specifies 1.0 days (24 hours) since > >1948-08-01 00:00. > > > >> ref_val of 0.0 does not work in ncvgt1 and > >> 1.0 does > > > >I don't understand this. How are you calling ncvgt1 and why is ref_val > >used as an argument? I wouldn't think ncvgt1 would take a > >double-precision argument such as ref_val. It requires integer indices > >to specify which value of a variable to get. > > > >> the data does start on Aug 1 1948 > >> > >> My question is ... is the second way the > >> correct way of working with time or does the > >> CDL need to be changed (with respect to bastime)? > > > >The CDL looks fine, and both your examples of calling uticaltime seem to > >return the correct value for the arguments you have given. It sounds > >like the problem is in the way you are calling ncvgt1. > > I am setting the ref_val to a integer indices that > is used as an agruement in ncvgt1. This I thought > would index me to the correct day in the file. > Is my thinking correct?? Will I get into trouble > doing it this way? It looks like I would have to > specify the end time of the day > > uticaltime(1948,8,1,24,0,0,t_unit,ref_val) > > to get the correct index into the file. Without seeing your NCVGT1 call, I can only guess what is going on here. Since you are using Fortran with array indices starting at 1 rather than 0, if your first day is 1948-08-01, then you should just add 1 to whatever is returned as ref_val by uticaltime and use that as a day index. That would give you an index of 1 for any valid time during the day 1948-08-01, 2 for 1948-08-02, etc. If you were using C, array indices start at 0, and you could use the integer-truncated ref_val value directly. Specifying the end time of the day using a time of 24:00 is another more roundabout way of just adding 1 to the number of days returned by your uticaltime call. _____________________________________________________________________ Russ Rew UCAR Unidata Program address@hidden http://www.unidata.ucar.edu