SURFEX  V8_0
Surfex V8_0 release
 All Classes Files Functions Variables
read_surf_atm_date.F90
Go to the documentation of this file.
1 !SFX_LIC Copyright 1994-2014 CNRS, Meteo-France and Universite Paul Sabatier
2 !SFX_LIC This is part of the SURFEX software governed by the CeCILL-C licence
3 !SFX_LIC version 1. See LICENSE, CeCILL-C_V1-en.txt and CeCILL-C_V1-fr.txt
4 !SFX_LIC for details. version 1.
5 ! #########
6  SUBROUTINE read_surf_atm_date (&
7  hprogram,hinit,kluout, &
8  hatmfile,hatmfiletype, &
9  kyear,kmonth,kday,ptime,tptime )
10 ! #######################################################
11 !
12 !!**** *READ_SURF_ATM_DATE* - routine to initialise the date TPTIME
13 !!
14 !! PURPOSE
15 !! -------
16 !!
17 !!** METHOD
18 !! ------
19 !!
20 !! EXTERNAL
21 !! --------
22 !!
23 !!
24 !! IMPLICIT ARGUMENTS
25 !! ------------------
26 !!
27 !! REFERENCE
28 !! ---------
29 !!
30 !!
31 !! AUTHOR
32 !! ------
33 !! S.Malardel *Meteo France*
34 !!
35 !! MODIFICATIONS
36 !! -------------
37 !! Original 01/2004
38 !! P. Le Moigne 10/2005, Phasage Arome
39 !-------------------------------------------------------------------------------
40 !
41 !* 0. DECLARATIONS
42 ! ------------
43 !
44 !
45 !
46 !
48 USE modd_surf_par, ONLY : xundef, nundef
49 !
50 USE modi_read_pre_surfa_dat_conf
51 USE modi_read_prep_surf_atm_conf
52 USE modi_read_prep_file_date
53 !
54 USE yomhook ,ONLY : lhook, dr_hook
55 USE parkind1 ,ONLY : jprb
56 !
57 USE modi_abor1_sfx
58 !
59 IMPLICIT NONE
60 !
61 !* 0.1 Declarations of arguments
62 ! -------------------------
63 !
64 !
65 !
66  CHARACTER(LEN=6), INTENT(IN) :: hprogram ! program calling ISBA
67  CHARACTER(LEN=3), INTENT(IN) :: hinit ! fields to initialize 'ALL', 'PRE', 'PGD'
68 TYPE (date_time), INTENT(OUT) :: tptime ! time and date
69 INTEGER, INTENT(IN) :: kluout ! logical unit of output listing
70  CHARACTER(LEN=28), INTENT(IN) :: hatmfile ! atmospheric file name
71  CHARACTER(LEN=6), INTENT(IN) :: hatmfiletype! atmospheric file type
72 INTEGER, INTENT(IN) :: kyear ! current year (UTC)
73 INTEGER, INTENT(IN) :: kmonth ! current month (UTC)
74 INTEGER, INTENT(IN) :: kday ! current day (UTC)
75 REAL, INTENT(IN) :: ptime ! current time since midnight (UTC, s)
76 !
77 !
78 !* 0.2 Declarations of local variables
79 ! -------------------------------
80 !
81  CHARACTER(LEN=28) :: yfile ! file name
82  CHARACTER(LEN=6) :: yfiletype ! file type
83  CHARACTER(LEN=28) :: yfilepgd ! file name
84  CHARACTER(LEN=6) :: yfilepgdtype ! file type
85  CHARACTER(LEN=28) :: yfilepgdin ! file name
86  CHARACTER(LEN=6) :: yfilepgdintype ! file type
87 REAL(KIND=JPRB) :: zhook_handle
88 !
89 !-------------------------------------------------------------------------------
90 !
91 IF (lhook) CALL dr_hook('READ_SURF_ATM_DATE',0,zhook_handle)
92 yfile = ' '
93 yfiletype = ' '
94 !
95 yfilepgdin = ' '
96 yfilepgdintype = ' '
97 !
98 !-------------------------------------------------------------------------------
99 !
100 !* look for a date in the namelist NAM_SURF_ATM
101 !----------------------------------------------
102 !
103  CALL read_pre_surfa_dat_conf(hprogram,kluout,tptime)
104 !
105 !* If no date in the namelist, look for a file
106 ! ---------------
107 !
108 IF (tptime%TDATE%YEAR==nundef.OR.tptime%TDATE%MONTH==nundef &
109  .OR.tptime%TDATE%DAY==nundef.OR.tptime%TIME==xundef) THEN
110 !
111  CALL read_prep_surf_atm_conf(hprogram,yfile,yfiletype,yfilepgd,yfilepgdtype,&
112  hatmfile,hatmfiletype,yfilepgdin,yfilepgdintype,kluout)
113 !
114  IF (len_trim(yfiletype)/=0) &
115  CALL read_prep_file_date(&
116  hprogram,yfile,yfiletype,tptime,kluout)
117 END IF
118 !
119 !* If no file and no date in the namelist, test if atmospheric date
120 !------------------------------------------------------------------
121 !
122 IF (len_trim(yfile)==0 .AND. (tptime%TDATE%YEAR==xundef.OR.tptime%TDATE%MONTH==xundef &
123  .OR.tptime%TDATE%DAY==xundef.OR.tptime%TIME==xundef)) THEN
124 !
125  IF (kyear /= nundef .AND. kmonth /= nundef .AND. kday /= nundef .AND. ptime /= xundef) THEN
126  tptime%TDATE%YEAR = kyear
127  tptime%TDATE%MONTH= kmonth
128  tptime%TDATE%DAY = kday
129  tptime%TIME = ptime
130  ELSE
131 !
132 !* If no file, no date in the namelist and no atmospheric date : stop
133 !-----------------------------------------------------------------------
134 !
135  CALL abor1_sfx('READ_SURF_ATM_DATE: DATE NOT SET')
136  END IF
137 END IF
138 !
139 !* Test of date coherence?
140 !------------------------
141 !
142 IF (kyear /= nundef .AND. kmonth /= nundef .AND. kday /= nundef .AND. ptime /= xundef) THEN
143  IF (kyear /= tptime%TDATE%YEAR .OR. kmonth /= tptime%TDATE%MONTH &
144  .OR. kday /= tptime%TDATE%DAY .AND. ptime /= tptime%TIME) THEN
145  WRITE(unit=kluout, fmt=*) 'WARNING in READ_SURF_ATM_DATE'
146  WRITE(unit=kluout, fmt=*) 'ATMOSPHERIC AND SURFACE DATES ARE NOT THE SAME'
147 
148  WRITE(unit=kluout, fmt=*)'ATMOSPHERIC DATE:'
149  WRITE(unit=kluout, fmt='(" YEAR=",I4)') kyear
150  WRITE(unit=kluout, fmt='(" MONTH=",I4)') kmonth
151  WRITE(unit=kluout, fmt='(" DAY=",I4)') kday
152  WRITE(unit=kluout, fmt='(" TIME=",E13.6)') ptime
153  WRITE(unit=kluout, fmt=*)'SURFACE DATE:'
154  WRITE(unit=kluout, fmt='(" YEAR=",I4)') tptime%TDATE%YEAR
155  WRITE(unit=kluout, fmt='(" MONTH=",I4)') tptime%TDATE%MONTH
156  WRITE(unit=kluout, fmt='(" DAY=",I4)') tptime%TDATE%DAY
157  WRITE(unit=kluout, fmt='(" TIME=",E13.6)') tptime%TIME
158  ELSE
159  WRITE(unit=kluout, fmt=*)'SAME ATMOSPHERIC AND SURFACE DATES'
160  WRITE(unit=kluout, fmt=*)'DATE in READ_SURF_ATM_DATE:'
161  WRITE(unit=kluout, fmt='(" YEAR=",I4," MONTH=",I4," DAY=",I4)') &
162  kyear,kmonth,kday
163  WRITE(unit=kluout, fmt='(" TIME=",E13.6)') ptime
164  ENDIF
165 ENDIF
166 IF (lhook) CALL dr_hook('READ_SURF_ATM_DATE',1,zhook_handle)
167 !------------------------------------------------------------------------------
168 !
169 END SUBROUTINE read_surf_atm_date
subroutine read_surf_atm_date(HPROGRAM, HINIT, KLUOUT, HATMFILE, HATMFILETYPE, KYEAR, KMONTH, KDAY, PTIME, TPTIME)
subroutine read_prep_file_date(HPROGRAM, HFILE, HFILETYPE, TPTIME, KLUOUT)
subroutine read_pre_surfa_dat_conf(HPROGRAM, KLUOUT, TPTIME)
subroutine abor1_sfx(YTEXT)
Definition: abor1_sfx.F90:6
subroutine read_prep_surf_atm_conf(HPROGRAM, HFILE, HFILETYPE, HFILEPGD, HFILEPGDTYPE, HATMFILE, HATMFILETYPE, HPGDFILE, HPGDFILETYPE, KLUOUT)