Due to the lapse in federal government funding, NASA is not updating this website. We sincerely regret this inconvenience.
NASA Logo
Ocean Color Science Software

ocssw V2022
yd2ymd.f
Go to the documentation of this file.
1 c -------------------------------------------------------------
2 c Subroutine yd2ymd
3 c
4 c Computes Month and Day of Month from Year and Day of Year
5 c
6 c year I I*4 4-digit year
7 c dayOfYear O I*4 day of year
8 c month I I*4 month number (1 - 12)
9 c dayOfMonth I I*4 day of month
10 c
11 c BA Franz, GSC, 12/96
12 c -------------------------------------------------------------
13 
14  subroutine yd2ymd(year,dayOfYear,month,dayOfMonth)
15 c
16  implicit none
17 c
18  save endofmonth
19 c
20  integer*4 year
21  integer*4 month
22  integer*4 dayOfMonth
23  integer*4 dayOfYear
24  integer*4 leap
25 c
26  integer*4 endOfMonth(12,2)
27 c
28  data endofmonth / 31,59,90,120,151,181,212,243,273,304,334,365,
29  . 31,60,91,121,152,182,213,244,274,305,335,366 /
30 c
31  if (mod(year,4) .eq. 0) then ! Not valid for year 2100
32  leap = 2
33  else
34  leap = 1
35  endif
36 c
37  month = 1
38  dowhile( dayofyear .gt. endofmonth(month,leap) )
39  month = month+1
40  enddo
41 c
42  if (month .gt. 1) then
43  dayofmonth = dayofyear - endofmonth(month-1,leap)
44  else
45  dayofmonth = dayofyear
46  endif
47 c
48  return
49  end
subroutine yd2ymd(year, dayOfYear, month, dayOfMonth)
Definition: yd2ymd.f:15