SURFEX  V8_0
Surfex V8_0 release
 All Classes Files Functions Variables
read_flake_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_flake_date (&
7  hprogram,hinit,kluout,hatmfile,hatmfiletype,&
8  kyear,kmonth,kday,ptime,tptime )
9 ! #######################################################
10 !
11 !!**** *READ_FLAKE_DATE* - initializes the date TTIME of MODD_FLAKE
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 : xundef, nundef
48 !
49 USE modi_read_pre_flake_dat_conf
50 USE modi_read_pre_surfa_dat_conf
51 USE modi_read_prep_flake_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 
79 !
80 !
81 !* 0.2 Declarations of local variables
82 ! -------------------------------
83 !
84  CHARACTER(LEN=28) :: yfile ! file name
85  CHARACTER(LEN=6) :: yfiletype ! file type
86  CHARACTER(LEN=28) :: yfilepgd ! file name
87  CHARACTER(LEN=6) :: yfilepgdtype ! file type
88  CHARACTER(LEN=28) :: yfilepgdin ! file name
89  CHARACTER(LEN=6) :: yfilepgdintype ! file type
90 !
91 LOGICAL :: gunif ! flag for prescribed uniform field
92 REAL(KIND=JPRB) :: zhook_handle
93 !
94 !-------------------------------------------------------------------------------
95 !
96 IF (lhook) CALL dr_hook('READ_FLAKE_DATE',0,zhook_handle)
97 yfile = ' '
98 yfiletype = ' '
99 !
100 yfilepgdin = ' '
101 yfilepgdintype = ' '
102 !
103 !-------------------------------------------------------------------------------
104 !
105 !* look for a date in the namelist NAM_PREP_FLAKE or NAM_PREP_SURF_ATM
106 !-----------------------------------------------------------------------
107 !
108  CALL read_pre_flake_dat_conf(hprogram,kluout,tptime)
109 !
110 IF (tptime%TDATE%YEAR==nundef.OR.tptime%TDATE%MONTH==nundef &
111  .OR.tptime%TDATE%DAY==nundef.OR.tptime%TIME==xundef) THEN
112  CALL read_pre_surfa_dat_conf(hprogram,kluout,tptime)
113 END IF
114 !
115 !* If no date in the namelist, look for a file
116 ! ---------------
117 !
118 IF (tptime%TDATE%YEAR==nundef.OR.tptime%TDATE%MONTH==nundef &
119  .OR.tptime%TDATE%DAY==nundef.OR.tptime%TIME==xundef) THEN
120  !
121  CALL read_prep_flake_conf(hprogram,'DATE ',yfile,yfiletype,yfilepgd,yfilepgdtype,&
122  hatmfile,hatmfiletype,yfilepgdin,yfilepgdintype,kluout,gunif)
123  !
124  IF (len_trim(yfiletype)/=0) &
125  CALL read_prep_file_date(&
126  hprogram,yfile,yfiletype,tptime,kluout)
127  !
128 END IF
129 !
130 !* If no file and no date in the namelist, test if atmospheric date
131 !------------------------------------------------------------------
132 !
133 IF (len_trim(yfile)==0 .AND. (tptime%TDATE%YEAR==nundef.OR.tptime%TDATE%MONTH==nundef &
134  .OR.tptime%TDATE%DAY==nundef.OR.tptime%TIME==xundef)) THEN
135 !
136  IF (kyear /= nundef .AND. kmonth /= nundef .AND. kday /= nundef .AND. ptime /= xundef) THEN
137  tptime%TDATE%YEAR = kyear
138  tptime%TDATE%MONTH= kmonth
139  tptime%TDATE%DAY = kday
140  tptime%TIME = ptime
141  ELSE
142 !
143 !* If no file, no date in the namelist and no atmospheric date : stop
144 !-----------------------------------------------------------------------
145 !
146  CALL abor1_sfx('READ_FLAKE_DATE: DATE NOT SET')
147  END IF
148 ENDIF
149 !
150 !* Test of date coherence?
151 !------------------------
152 !
153 IF (kyear /= nundef .AND. kmonth /= nundef .AND. kday /= nundef .AND. ptime /= xundef) THEN
154  IF (kyear /= tptime%TDATE%YEAR .OR. kmonth /= tptime%TDATE%MONTH .OR. kday /= tptime%TDATE%DAY .AND. ptime /= tptime%TIME) THEN
155  WRITE(unit=kluout, fmt=*)'WARNING in READ_FLAKE_DATE'
156  WRITE(unit=kluout, fmt=*)'ATMOSPHERIC AND SURFACE DATES ARE NOT THE SAME'
157 
158  WRITE(unit=kluout, fmt=*)'ATMOSPHERIC DATE:'
159  WRITE(unit=kluout, fmt='(" YEAR=",I4)') kyear
160  WRITE(unit=kluout, fmt='(" MONTH=",I4)') kmonth
161  WRITE(unit=kluout, fmt='(" DAY=",I4)') kday
162  WRITE(unit=kluout, fmt='(" TIME=",E13.6)') ptime
163  WRITE(unit=kluout, fmt=*)'SURFACE DATE:'
164  WRITE(unit=kluout, fmt='(" YEAR=",I4)') tptime%TDATE%YEAR
165  WRITE(unit=kluout, fmt='(" MONTH=",I4)') tptime%TDATE%MONTH
166  WRITE(unit=kluout, fmt='(" DAY=",I4)') tptime%TDATE%DAY
167  WRITE(unit=kluout, fmt='(" TIME=",E13.6)') tptime%TIME
168  ELSE
169  WRITE(unit=kluout, fmt=*)'SAME ATMOSPHERIC AND SURFACE DATES'
170  WRITE(unit=kluout, fmt=*)'DATE in READ_FLAKE_DATE'
171  WRITE(unit=kluout, fmt='(" YEAR=",I4," MONTH=",I4," DAY=",I4)') &
172  kyear,kmonth,kday
173  WRITE(unit=kluout, fmt='(" TIME=",E13.6)') ptime
174  ENDIF
175 ENDIF
176 IF (lhook) CALL dr_hook('READ_FLAKE_DATE',1,zhook_handle)
177 !------------------------------------------------------------------------------
178 !
179 END SUBROUTINE read_flake_date
subroutine read_flake_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_flake_conf(HPROGRAM, HVAR, HFILE, HFILETYPE, HFILEPGD, HFILEPGDTYPE, HATMFILE, HATMFILETYPE, HPGDFILE, HPGDFILETYPE, KLUOUT, OUNIF)
subroutine read_pre_flake_dat_conf(HPROGRAM, KLUOUT, TPTIME)