c date: converts from calendar to day number and back. c******************************************* logical*1 truth 55 call print('enter year (eg: 96)') read (*,*)iy if(truth('want calendar date?'))then iway=0 call print('enter day number: (eg: 123)') read(*,*)jd call julian(iy,im,id,jd,iway) write(*,22)iy,im,id 22 format('year: ',i2.2,' month: ',i2.2,' day: ',i2.2) else iway=1 call print('enter month and day: (eg: 0112)') read(*,'(2(i2.2))')im,id call julian(iy,im,id,jd,iway) write(*,33)jd 33 format('Day number is:',i3) endif if(truth('again?'))goto 55 stop end subroutine julian(iy,im,id,jd,iway) c c gives day number c integer mo(12) data mo/31,28,31,30,31,30,31,31,30,31,30,31/ leap=0 if(iy.eq.80.or.iy.eq.84.or.iy.eq.88.or.iy.eq.92)leap=1 if(iy.eq.96)leap=1 mo(2)=28+leap c if(iway.eq.1)then ! go from calendar to day number jd=0 c if(im.eq.1)then goto 5 else do 2 i=1,im-1 jd=jd+mo(i) 2 continue endif c 5 jd=jd+id return endif c if(iway.eq.0)then c inverse transform sum=0 do 4 i=1,12 sum=sum+mo(i) itest=jd-sum if(itest.le.0)then im=i goto 66 endif 4 continue 66 continue if(im.eq.1)id=jd if (im.ne.1)id=jd-sum+mo(im) endif return end