SURFEX v8.1
General documentation of Surfex
trip_date.F90
Go to the documentation of this file.
1 SUBROUTINE trip_date(KYEAR,KMONTH,KDAY,PTIME)
2 !#######################################################
3 !
4 !!**** *TRIP_DATE* - current date and hour
5 !!
6 !-------------------------------------------------------------------------------
7 !
8 !* 0. DECLARATIONS
9 ! ------------
10 !
11 !
12 USE yomhook ,ONLY : lhook, dr_hook
13 USE parkind1 ,ONLY : jprb
14 !
15 IMPLICIT NONE
16 !
17 !* 0.1 Declaration of arguments
18 ! ------------------------
19 !
20 INTEGER, INTENT(INOUT) :: KYEAR ! year of date
21 INTEGER, INTENT(INOUT) :: KMONTH ! month of date
22 INTEGER, INTENT(INOUT) :: KDAY ! day of date
23 REAL, INTENT(INOUT) :: PTIME ! number of seconds since date at 00 UTC
24 !
25 !* 0.2 Declaration of local variables
26 ! ------------------------------
27 !
28 INTEGER :: IDAYS ! number of days in KMONTH
29 !
30 REAL(KIND=JPRB) :: ZHOOK_HANDLE
31 !-------------------------------------------------------------------------------
32 !
33 !* 1. Return condition: less than one day to add
34 ! ------------------------------------------
35 !
36 IF (lhook) CALL dr_hook('TRIP_DATE',0,zhook_handle)
37 !
38 DO
39  IF (86400.-ptime > 1.e-6) EXIT
40 !
41 !-------------------------------------------------------------------------------
42 !
43 !* 2. Adding one day
44 ! --------------
45 !
46  ptime=ptime-86400.
47 !
48 !* 2.1 Number of days in a month
49 ! -------------------------
50 !
51  SELECT CASE (kmonth)
52  CASE(4,6,9,11)
53  idays=30
54  CASE(1,3,5,7:8,10,12)
55  idays=31
56  CASE(2)
57  IF( ((mod(kyear,4)==0).AND.(mod(kyear,100)/=0)) .OR. (mod(kyear,400)==0))THEN
58  idays=29
59  ELSE
60  idays=28
61  ENDIF
62  END SELECT
63 !
64 !* 2.2 Last day of the month
65 ! ---------------------
66 !
67  IF (kday==idays) THEN
68  IF (kmonth==12) THEN
69  kday=1
70  kmonth=1
71  kyear=kyear+1
72  ELSE
73  kday=1
74  kmonth=kmonth+1
75  ENDIF
76 !
77 !* 2.3 Other days
78 ! ----------
79  ELSE
80  kday=kday+1
81  ENDIF
82 !
83 ENDDO
84 !
85 IF (lhook) CALL dr_hook('TRIP_DATE',1,zhook_handle)
86 !
87 !-------------------------------------------------------------------------------
88 !
89 END SUBROUTINE trip_date
integer, parameter jprb
Definition: parkind1.F90:32
logical lhook
Definition: yomhook.F90:15
subroutine trip_date(KYEAR, KMONTH, KDAY, PTIME)
Definition: trip_date.F90:2