time conversion

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

  • 2005 messages navigation, sorted by:
    1. Thread
    2. Subject
    3. Author
    4. Date
    5. ↑ Table Of Contents
  • Search the netcdfgroup archives: