SURFEX v8.1
General documentation of Surfex
trip_forcing_conf.F90
Go to the documentation of this file.
1 !######
2 SUBROUTINE trip_forcing_conf(KLISTING,KYEAR,KMONTH,KDAY,PTIME, &
3  HFILE_FRC,HREADFRC,HDRAIN,HRUNOFF, &
4  KLON,KLAT,PTSTEP_RUN,KNB_TSTEP_RUN,&
5  PRUNTIME )
6 !#######################################################################
7 !
8 !!**** *TRIP_FORCING_CONF* - prepare the dimenssions (xt or xyt) of run
9 !!
10 !! PURPOSE
11 !! -------
12 !!
13 !!** METHOD
14 !! ------
15 !!
16 !! EXTERNAL
17 !! --------
18 !!
19 !!
20 !! IMPLICIT ARGUMENTS
21 !! ------------------
22 !!
23 !! REFERENCE
24 !! ---------
25 !!
26 !!
27 !! AUTHOR
28 !! ------
29 !! B. decharme *Meteo France*
30 !!
31 !! MODIFICATIONS
32 !! -------------
33 !! Original 06/2008
34 !-------------------------------------------------------------------------------
35 !
36 !* 0. DECLARATIONS
37 ! ------------
38 !
39 USE modd_trip_par, ONLY : xday
40 !
41 USE modi_abort_trip
42 USE modi_read_dimlen
43 USE modi_read_forcing_date
44 !
45 USE yomhook ,ONLY : lhook, dr_hook
46 USE parkind1 ,ONLY : jprb
47 !
48 IMPLICIT NONE
49 !
50 !* 0.1 Declarations of arguments
51 ! -------------------------
52 !
53 INTEGER, INTENT(IN) :: KLISTING
54 INTEGER, INTENT(IN) :: KYEAR
55 INTEGER, INTENT(IN) :: KMONTH
56 INTEGER, INTENT(IN) :: KDAY
57 REAL, INTENT(IN) :: PTIME
58 !
59  CHARACTER(LEN=15), INTENT(IN) :: HFILE_FRC
60  CHARACTER(LEN=6), INTENT(IN) :: HREADFRC
61  CHARACTER(LEN=8), INTENT(IN) :: HDRAIN
62  CHARACTER(LEN=8), INTENT(IN) :: HRUNOFF
63 INTEGER, INTENT(IN) :: KLON
64 INTEGER, INTENT(IN) :: KLAT
65 REAL, INTENT(IN) :: PTSTEP_RUN
66 !
67 INTEGER, INTENT(OUT) :: KNB_TSTEP_RUN
68 REAL, INTENT(OUT) :: PRUNTIME
69 !
70 !
71 !* 0.2 Declarations of local variables
72 ! -------------------------------
73 !
74 INTEGER, DIMENSION (:), ALLOCATABLE :: IDIMLEN
75 !
76 INTEGER :: INDIM
77 INTEGER :: ILON
78 INTEGER :: ILAT
79 INTEGER :: INI
80 INTEGER :: IWORK1, IWORK2
81 !
82 INTEGER :: IYEAR
83 INTEGER :: IMONTH
84 INTEGER :: IDAY
85 REAL :: ZTIME
86 !
87 REAL(KIND=JPRB) :: ZHOOK_HANDLE
88 !
89 !-------------------------------------------------------------------------------
90 ! Read the configuration of the run
91 !-------------------------------------------------------------------------------
92 IF (lhook) CALL dr_hook('TRIP_FORCING_CONF',0,zhook_handle)
93 !
94 IF(hreadfrc=='VECTOR')THEN
95  indim=2
96 ELSE
97  indim=3
98 ENDIF
99 !
100 ALLOCATE(idimlen(indim))
101 idimlen=0
102 !
103  CALL read_dimlen(klisting,hfile_frc,hdrain,indim,idimlen)
104 !
105 IF(hreadfrc=='VECTOR')THEN
106 !
107  ini = idimlen(1)
108  iwork1 = idimlen(2)
109 !
110  IF(ini/=klon*klat)THEN
111  WRITE(klisting,*)'For the variable DRAIN : '
112  WRITE(klisting,*)'TRIP_FORCING_CONF : The number of points in the forcing variables (',ini,')'
113  WRITE(klisting,*)'are /= of the number of points in the TRIP domain'
114  WRITE(klisting,*)'NLON = ',klon,' and NLAT = ',klat,' so the number of points = ',klon*klat
115  CALL abort_trip('TRIP_FORCING_CONF: number of points in the forcing variables are /= than TRIP domain')
116  ENDIF
117 !
118 ELSE
119 !
120  ilon = idimlen(1)
121  ilat = idimlen(2)
122  iwork1 = idimlen(3)
123  ini = ilon*ilat
124 !
125  IF(ini/=klon*klat)THEN
126  WRITE(klisting,*)'For the variable DRAIN : '
127  WRITE(klisting,*)'TRIP_FORCING_CONF : The number of points in the forcing variables (',ilon*ilat,')'
128  WRITE(klisting,*)'are /= of the number of points in the TRIP domain'
129  WRITE(klisting,*)'NLON = ',klon,' and NLAT = ',klat,' while FRC_LON = ',ilon,' and FRC_LAT = ',ilat
130  CALL abort_trip('TRIP_FORCING_CONF: number of points in the forcing variables are /= than TRIP domain')
131  ENDIF
132 !
133 ENDIF
134 !
135 idimlen=0
136 !
137  CALL read_dimlen(klisting,hfile_frc,hrunoff,indim,idimlen)
138 !
139 IF(hreadfrc=='VECTOR')THEN
140 !
141  ini = idimlen(1)
142  iwork2 = idimlen(2)
143 !
144  IF(ini/=klon*klat)THEN
145  WRITE(klisting,*)'For the variable RUNOFF : '
146  WRITE(klisting,*)'TRIP_FORCING_CONF : The number of points in the forcing variables (',ini,')'
147  WRITE(klisting,*)'are /= of the number of points in the TRIP domain'
148  WRITE(klisting,*)'NLON = ',klon,' and NLAT = ',klat,' so the number of points = ',klon*klat
149  CALL abort_trip('TRIP_FORCING_CONF: number of points in the forcing variables are /= than TRIP domain')
150  ENDIF
151 !
152 ELSE
153 !
154  ilon = idimlen(1)
155  ilat = idimlen(2)
156  iwork2 = idimlen(3)
157  ini = ilon*ilat
158 !
159  IF(ini/=klon*klat)THEN
160  WRITE(klisting,*)'For the variable RUNOFF : '
161  WRITE(klisting,*)'TRIP_FORCING_CONF : The number of points in the forcing variables (',ilon*ilat,')'
162  WRITE(klisting,*)'are different than the number of points in the TRIP domain'
163  WRITE(klisting,*)'NLON = ',klon,' and NLAT = ',klat,' while FRC_LON = ',ilon,' and FRC_LAT = ',ilat
164  CALL abort_trip('TRIP_FORCING_CONF: number of points in the forcing variables are /= than TRIP domain')
165  ENDIF
166 !
167 ENDIF
168 !
169 DEALLOCATE(idimlen)
170 !
171 !-------------------------------------------------------------------------------
172 ! Configuration of the run
173 !-------------------------------------------------------------------------------
174 !
175 ! * Number of time step during the run
176 !
177 IF(iwork1/=iwork2)THEN
178  WRITE(klisting,*)'TRIP_FORCING_CONF : The number of time step are different for each forcing variable !'
179  WRITE(klisting,*)'NB_TSTEP for DRAIN = ',iwork1,' while NB_TSTEP for RUNOFF = ',iwork2
180  CALL abort_trip('TRIP_FORCING_CONF: The number of time step are different for each forcing variable')
181 ELSE
182  knb_tstep_run = iwork1
183 ENDIF
184 !
185 pruntime = REAL(KNB_TSTEP_RUN) * PTSTEP_RUN
186 !
187 ! * Date the run
188 !
189  CALL read_forcing_date(klisting,hfile_frc,knb_tstep_run, &
190  iyear,imonth,iday,ztime )
191 !
192 IF ( (kyear /= iyear) .OR. (kmonth /= imonth) .OR. (kday /= iday) .OR. (ptime /= ztime)) THEN
193  WRITE(klisting,*)' DATE INCONSISTENCY: RESTART FILE = ',kyear,kmonth,kday,ptime
194  WRITE(klisting,*)' DATE INCONSISTENCY: FORCING FILE = ',iyear,imonth,iday,ztime
195  CALL abort_trip('TRIP_FORCING_CONF: DATE INCONSISTENCY')
196 ENDIF
197 !
198 IF (lhook) CALL dr_hook('TRIP_FORCING_CONF',1,zhook_handle)
199 !-------------------------------------------------------------------------------
200 !
201 END SUBROUTINE trip_forcing_conf
subroutine trip_forcing_conf(KLISTING, KYEAR, KMONTH, KDAY, PTIME, HFILE_FRC, HREADFRC, HDRAIN, HRUNOFF, KLON, KLAT, PTSTEP_RUN, KNB_TSTEP_RUN, PRUNTIME)
real, save xday
subroutine read_forcing_date(KLISTING, HFILE, KNB_TSTEP_RUN, KYEAR, KMONTH, KDAY, PTIME)
integer, parameter jprb
Definition: parkind1.F90:32
logical lhook
Definition: yomhook.F90:15
subroutine read_dimlen(KLUOUT, HFILE, HVAR, KDIM, KDIMLEN)
Definition: read_dimlen.F90:3
subroutine abort_trip(YTEXT)
Definition: abort_trip.F90:3