      SUBROUTINE NAILUJt(iyear0,iyear,month,iday,time,itimesig,
     *                   xjulian,jsig)

C    COMPUTES CALENDAR DAY FROM JULIAN DAY, INCLUDING TIME, WITH RESPECTS
C    TO MIDNIGHT JANUARY 1 OF THE BASE YEAR

C    ADAPTED FROM ORIGINAL SUBROUTINE CREATED BY LINDA STATHOPOLIS

c*************************************************************
c
c    Passed variables
c
c     iyear0 - base year for calculating julian day
c     iyear - present year
c     month,iday - present month,day
c     time - present time
c     itimesig - number of significant figures in time
c     xjulian - output julian day
c     jsig - output number of significant figures for julian day
c
c************************************************************

      parameter (bmiss=-1E10,zdays=365.,tmiss=99.99)
      dimension yrnorm(13)

      data yrnorm/0,31,59,90,120,151,181,212,243,273,304,334,365/

      if ( xjulian .le. bmiss ) then
       iyear=-9999
       month=-99
       iday=-99
       return
      endif

      xadd=0.
      iyearadd=0
      xjulian0=xjulian

      iyear=0
      month=0
      iday=0

      if ( (iyear0/4)*4 .eq. iyear0 ) xadd=1.
      if ( (iyear0/100)*100 .eq. iyear0 .and.
     *     (iyear0/400)*400 .ne. iyear0 ) xadd=0.
   
      xj0=xjulian
      ineg=0
      if ( xjulian .lt. 0 ) then
       ineg=1
       xj0=-xj0
      endif
      if ( xj0 .ge. zdays+xadd )
     * call reducejulian(iyear0,xjulian0,iyearadd)

c     Set year

      xadd=0.
      iyear=iyear0+iyearadd
      if ( (iyear/4)*4 .eq. iyear ) xadd=1.
      if ( (iyear/100)*100 .eq. iyear .and.
     *     (iyear/400)*400 .ne. iyear ) xadd=0.

c     Set month

      xj0=xjulian0
      if ( ineg .eq. 1 ) xj0=xjulian0+yrnorm(13)+xadd
      x1=0.
      do 30 mm=2,13

       if ( mm .eq. 3 ) x1=xadd
       if ( xj0 .lt. yrnorm(mm)+x1 ) then
        month=mm-1
        goto 31
       endif
30     continue
31     continue

c     Set day

      iday=xj0-yrnorm(month)+1.
      if ( month .ge. 3 .and. xadd .gt. 0. ) iday=iday-1

c     Set time

      ijulian=xj0
      xjuliant=ijulian
      time=(xj0-xjuliant)*24.

c     Set time significant figures

      call findprecone(itimesig,jsig,xjulian)

c     Round time

      call roundoff(-itimesig,time)
      if ( itimesig .eq. 0 ) time=tmiss
 
      return
      end
