NOTICE: This version of the NSF Unidata web site (archive.unidata.ucar.edu) is no longer being updated.
Current content can be found at unidata.ucar.edu.
To learn about what's going on, see About the Archive Site.
Hi, You want to be really careful with converting hours since 1-1-1 into year-month-day. I think you will be aware that years are not exactly 365.25 days long. To get around this you need to drop the leap years at the century, unless the century is divisible by 400 (1700, 1800 and 1900 were not leap years, but 2000 was). This is called (I think) Gregorian time, and I guess it was introduced by Pope Gregory. Before that, Julian time was used, where every year divisible by four was a leap year. However, not all countries implemented the newer system at the same time (I don't think Russia introduced it until approximately the time of the Revolution, from memory), so that adds another complication. You should be OK negelecting leap seconds ... but I really don't know. I'm not sure if leap seconds were "invented" before the 1970s. However if they were, after 2000 years, the number of leap seconds will be close to one hour. Really, it might be better to keep your original units. You probably don't want to open up the can of worms which the time and calender system is. Tim. On Thu, 24 Feb 2005 12:17:02 -0800 araligin@xxxxxxxxxxxxx wrote: > > Hi, > > I have my time variable reading below for the netcdf file > double time(time) ; > time:units = "hours since 1-1-1 00:00:0.0" ; > time:long_name = "Time" ; > time:actual_range = 17461560., 17549208. ; > time:delta_t = "0000-00-01 00:00:00" ; > > > my first data is from 01 Jan 1993. I read the time as double > precision and > convert it to integer and give input to the subroutine which converts > into UTC. But I get the first date as 27 Nov 1993. following is the > subroutine. > > subroutine ymd(jn) > integer W,X,A,B,C,D,E,F > integer mnt,yr,day > integer jn,Z > write(*,*) jn > jn=int(jn/24.0) > z=jn > w=int((z - 1867216.25)/36524.25) > c w=z/36524.25 > c w=z > C x=int(w/4) > a=z+1+w-int(0.250*w) > write(*,*) w,x,a > b=a+1524 > c=int( 6680.0+((b-2439870)-122.1)/365.25) > d = 365*c+int(0.25*c) > e= int((b-d)/30.6001) > f= int(30.6001*e) > write(*,*) b,c,d,e,f > day= b - d - f > if(e.lt.13.5) then > mnth=e-1 > else > mnth=e-13 > endif > if(mnth.le.2) yr = c -1 > if(mnth.gt.2) yr = c-2 > write(12,*) yr,mnth,day > return > END > > > Thanking you, > Nilesh >
netcdfgroup
archives: