SURFEX  V8_0
Surfex V8_0 release
 All Classes Files Functions Variables
read_teb_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_teb_date (&
7  hprogram,hinit,kluout,hatmfile,hatmfiletype,&
8  kyear,kmonth,kday,ptime,tptime)
9 ! #######################################################
10 !
11 !!**** *READ_TEB_DATE* - routine to initialise de date TTIME of MODD_TEB
12 !!
13 !! PURPOSE
14 !! -------
15 !!
16 !!** METHOD
17 !! ------
18 !!
19 !! EXTERNAL
20 !! --------
21 !!
22 !!
23 !! IMPLICIT ARGUMENTS
24 !! ------------------
25 !!
26 !! REFERENCE
27 !! ---------
28 !!
29 !!
30 !! AUTHOR
31 !! ------
32 !! S.Malardel *Meteo France*
33 !!
34 !! MODIFICATIONS
35 !! -------------
36 !! Original 01/2004
37 !! P. Le Moigne 10/2005, Phasage Arome
38 !-------------------------------------------------------------------------------
39 !
40 !* 0. DECLARATIONS
41 ! ------------
42 !
43 !
44 !
45 !
47 USE modd_surf_par, ONLY : nundef, xundef
48 !
49 USE modi_read_prep_teb_date_conf
50 USE modi_read_pre_surfa_dat_conf
51 USE modi_read_prep_teb_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
67  CHARACTER(LEN=3), INTENT(IN) :: hinit ! fields to initialize 'ALL', 'PRE', 'PGD'
68  CHARACTER(LEN=28), INTENT(IN) :: hatmfile ! atmospheric file name
69  CHARACTER(LEN=6), INTENT(IN) :: hatmfiletype! atmospheric file type
70 INTEGER, INTENT(IN) :: kyear ! current year (UTC)
71 INTEGER, INTENT(IN) :: kmonth ! current month (UTC)
72 INTEGER, INTENT(IN) :: kday ! current day (UTC)
73 REAL, INTENT(IN) :: ptime ! current time since midnight (UTC, s)
74 TYPE (date_time), INTENT(OUT) ::tptime ! time and date
75 INTEGER, INTENT(IN) :: kluout ! logical unit of output listing
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 !
88 LOGICAL :: gunif ! flag for prescribed uniform field
89 REAL(KIND=JPRB) :: zhook_handle
90 !
91 !-------------------------------------------------------------------------------
92 !
93 IF (lhook) CALL dr_hook('READ_TEB_DATE',0,zhook_handle)
94 yfile = ' '
95 yfiletype = ' '
96 !
97 yfilepgdin = ' '
98 yfilepgdintype = ' '
99 !
100 !-------------------------------------------------------------------------------
101 !
102 !* look for a date in the namelist NAM_PREP_TEB or NAM_PREP_SURF_ATM
103 !-------------------------------------------------------------------
104 !
105  CALL read_prep_teb_date_conf(hprogram,kluout,tptime)
106 !
107 IF (tptime%TDATE%YEAR==nundef.OR.tptime%TDATE%MONTH==nundef &
108  .OR.tptime%TDATE%DAY==nundef.OR.tptime%TIME==xundef) THEN
109  CALL read_pre_surfa_dat_conf(hprogram,kluout,tptime)
110 END IF
111 !
112 !* If no date in the namelist, look for a file
113 ! ---------------
114 !
115 IF (tptime%TDATE%YEAR==nundef.OR.tptime%TDATE%MONTH==nundef &
116  .OR.tptime%TDATE%DAY==nundef.OR.tptime%TIME==xundef) THEN
117  !
118  CALL read_prep_teb_conf(hprogram,'DATE ',yfile,yfiletype,yfilepgd,yfilepgdtype,&
119  hatmfile,hatmfiletype,yfilepgdin,yfilepgdintype,kluout,gunif)
120  !
121  IF (len_trim(yfiletype)/=0) THEN
122  CALL read_prep_file_date(&
123  hprogram,yfile,yfiletype,tptime,kluout)
124  END IF
125  !
126 END IF
127 !
128 !* If no file and no date in the namelist, test if atmospheric date
129 !------------------------------------------------------------------
130 !
131 IF (len_trim(yfile)==0 .AND. (tptime%TDATE%YEAR==nundef.OR.tptime%TDATE%MONTH==nundef &
132  .OR.tptime%TDATE%DAY==nundef.OR.tptime%TIME==xundef)) THEN
133 !
134  IF (kyear /= nundef .AND. kmonth /= nundef .AND. kday /= nundef .AND. ptime /= xundef) THEN
135  tptime%TDATE%YEAR = kyear
136  tptime%TDATE%MONTH= kmonth
137  tptime%TDATE%DAY = kday
138  tptime%TIME = ptime
139  ELSE
140 !
141 !* If no file, no date in the namelist and no atmospheric date : stop
142 !-----------------------------------------------------------------------
143 !
144  CALL abor1_sfx('READ_TEB_DATE: DATE NOT SET')
145  END IF
146 ENDIF
147 !
148 !* Test of date coherence?
149 !------------------------
150 !
151 IF (kyear /= nundef .AND. kmonth /= nundef .AND. kday /= nundef .AND. ptime /= xundef) THEN
152  IF (kyear /= tptime%TDATE%YEAR .OR. kmonth /= tptime%TDATE%MONTH .OR. kday /= tptime%TDATE%DAY .AND. ptime /= tptime%TIME) THEN
153  WRITE(unit=kluout, fmt=*)'WARNING in READ_TEB_DATE'
154  WRITE(unit=kluout, fmt=*)'ATMOSPHERIC AND SURFACE DATES ARE NOT THE SAME'
155  WRITE(unit=kluout, fmt=*)'ATMOSPHERIC DATE:'
156  WRITE(unit=kluout, fmt='(" YEAR=",I4)') kyear
157  WRITE(unit=kluout, fmt='(" MONTH=",I4)') kmonth
158  WRITE(unit=kluout, fmt='(" DAY=",I4)') kday
159  WRITE(unit=kluout, fmt='(" TIME=",E13.6)') ptime
160  WRITE(unit=kluout, fmt=*)'SURFACE DATE:'
161  WRITE(unit=kluout, fmt='(" YEAR=",I4)') tptime%TDATE%YEAR
162  WRITE(unit=kluout, fmt='(" MONTH=",I4)') tptime%TDATE%MONTH
163  WRITE(unit=kluout, fmt='(" DAY=",I4)') tptime%TDATE%DAY
164  WRITE(unit=kluout, fmt='(" TIME=",E13.6)') tptime%TIME
165  ELSE
166  WRITE(unit=kluout, fmt=*)'SAME ATMOSPHERIC AND SURFACE DATES'
167  WRITE(unit=kluout, fmt=*)'DATE in READ_TEB_DATE'
168  WRITE(unit=kluout, fmt='(" YEAR=",I4," MONTH=",I4," DAY=",I4)') &
169  kyear,kmonth,kday
170  WRITE(unit=kluout, fmt='(" TIME=",E13.6)') ptime
171  ENDIF
172 ENDIF
173 IF (lhook) CALL dr_hook('READ_TEB_DATE',1,zhook_handle)
174 !------------------------------------------------------------------------------
175 !
176 END SUBROUTINE read_teb_date
subroutine read_prep_teb_conf(HPROGRAM, HVAR, HFILE, HFILETYPE, HFILEPGD, HFILEPGDTYPE, HATMFILE, HATMFILETYPE, HPGDFILE, HPGDFILETYPE, KLUOUT, OUNIF)
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_teb_date_conf(HPROGRAM, KLUOUT, TPTIME)
subroutine read_teb_date(HPROGRAM, HINIT, KLUOUT, HATMFILE, HATMFILETYPE, KYEAR, KMONTH, KDAY, PTIME, TPTIME)