Juan 24/05/2017: add MPPDB_CHECK on SURFEX routine for reprod check with MNH_PARALLEL key
[MNH-git_open_source-lfs.git] / src / SURFEX / read_pgd_tebn.F90
1 !SURFEX_LIC Copyright 1994-2014 Meteo-France 
2 !SURFEX_LIC This is part of the SURFEX software governed by the CeCILL-C  licence
3 !SURFEX_LIC version 1. See LICENSE, CeCILL-C_V1-en.txt and CeCILL-C_V1-fr.txt
4 !SURFEX_LIC for details. version 1.
5 !     #########
6       SUBROUTINE READ_PGD_TEB_n(HPROGRAM)
7 !     #########################################
8 !
9 !!****  *READ_PGD_TEB_n* - reads TEB physiographic fields
10 !!                       
11 !!
12 !!    PURPOSE
13 !!    -------
14 !!
15 !!**  METHOD
16 !!    ------
17 !!
18 !!    EXTERNAL
19 !!    --------
20 !!
21 !!
22 !!    IMPLICIT ARGUMENTS
23 !!    ------------------
24 !!
25 !!    REFERENCE
26 !!    ---------
27 !!
28 !!
29 !!    AUTHOR
30 !!    ------
31 !!      V. Masson   *Meteo France*      
32 !!
33 !!    MODIFICATIONS
34 !!    -------------
35 !!      Original    01/2003 
36 !!      M. Moge     02/2015 READ_SURF // + MPPDB_CHECK
37 !-------------------------------------------------------------------------------
38 !
39 !*       0.    DECLARATIONS
40 !              ------------
41 !
42 USE MODD_TYPE_DATE_SURF
43 !
44 USE MODD_DATA_COVER_PAR, ONLY : JPCOVER
45 !
46 USE MODD_TEB_n,          ONLY : XCOVER, XZS, CBEM,                     &
47                                 NROOF_LAYER, NROAD_LAYER, NWALL_LAYER, &
48                                 TTIME, LCOVER, LECOCLIMAP, NTEB_PATCH, &
49                                 CBLD_ATYPE, LGARDEN,                   &
50                                 LGREENROOF
51 USE MODD_BEM_n,          ONLY : NFLOOR_LAYER, CCOOL_COIL, CHEAT_COIL, LAUTOSIZE
52 USE MODD_TEB_GRID_n,     ONLY : XLAT, XLON, XMESH_SIZE, CGRID, XGRID_PAR, NDIM
53 !
54 !
55 USE MODI_READ_SURF
56 USE MODI_READ_GRID
57 USE MODI_READ_LCOVER
58 USE MODI_READ_PGD_TEB_PAR_n
59 !
60 !
61 USE YOMHOOK   ,ONLY : LHOOK,   DR_HOOK
62 USE PARKIND1  ,ONLY : JPRB
63 !
64 USE MODI_GET_TYPE_DIM_n
65 !
66 USE MODI_READ_LECOCLIMAP
67 !
68 #ifdef MNH_PARALLEL
69 USE MODI_GET_LUOUT
70 USE MODE_MPPDB
71 !
72 #endif
73 IMPLICIT NONE
74 !
75 !*       0.1   Declarations of arguments
76 !              -------------------------
77 !
78  CHARACTER(LEN=6),  INTENT(IN)  :: HPROGRAM ! calling program
79 !
80 !*       0.2   Declarations of local variables
81 !              -------------------------------
82 !
83 INTEGER           :: IRESP          ! Error code after redding
84 #ifdef MNH_PARALLEL
85 INTEGER :: ILUOUT  ! output listing logical unit
86 #endif
87 !
88  CHARACTER(LEN=LEN_HREC) :: YRECFM         ! Name of the article to be read
89 INTEGER           :: IVERSION
90 INTEGER           :: IBUGFIX
91 !
92 REAL(KIND=JPRB) :: ZHOOK_HANDLE
93 !-------------------------------------------------------------------------------
94 !
95 !* 1D physical dimension
96 !
97 IF (LHOOK) CALL DR_HOOK('READ_PGD_TEB_N',0,ZHOOK_HANDLE)
98 #ifdef MNH_PARALLEL
99  CALL GET_LUOUT(HPROGRAM,ILUOUT)
100 #endif
101 YRECFM='SIZE_TOWN'
102  CALL GET_TYPE_DIM_n('TOWN  ',NDIM)
103 !
104 !*       2.     Other dimension initializations:
105 !               --------------------------------
106 !
107  CALL READ_SURF(HPROGRAM,'VERSION',IVERSION,IRESP)
108  CALL READ_SURF(HPROGRAM,'BUG',IBUGFIX,IRESP)
109 !
110 !* number of TEB patches
111 !
112 IF (IVERSION<7 .OR. IVERSION==7 .AND. IBUGFIX<=2) THEN
113   NTEB_PATCH=1
114 ELSE
115   YRECFM='TEB_PATCH'
116   CALL READ_SURF(HPROGRAM,YRECFM,NTEB_PATCH,IRESP)
117 END IF
118 !
119 !* number of road and roof layers
120 !
121 YRECFM='ROAD_LAYER'
122  CALL READ_SURF(HPROGRAM,YRECFM,NROAD_LAYER,IRESP)
123
124 YRECFM='ROOF_LAYER'
125  CALL READ_SURF(HPROGRAM,YRECFM,NROOF_LAYER,IRESP)
126
127 YRECFM='WALL_LAYER'
128  CALL READ_SURF(HPROGRAM,YRECFM,NWALL_LAYER,IRESP)
129 !
130 !
131 !* type of averaging for Buildings (to allow ascendant compatibility)
132 !* type of Building Energy Model
133 !
134 IF (IVERSION<7 .OR.( IVERSION==7 .AND. IBUGFIX<=2)) THEN
135   CBLD_ATYPE='ARI'
136   CBEM = 'DEF'
137 ELSE
138   YRECFM='BLD_ATYPE'
139   CALL READ_SURF(HPROGRAM,YRECFM,CBLD_ATYPE,IRESP)
140   YRECFM='BEM'
141   CALL READ_SURF(HPROGRAM,YRECFM,CBEM,IRESP)
142 END IF
143 !
144 IF (CBEM=="BEM") THEN
145   YRECFM='FLOOR_LAYER'
146   CALL READ_SURF(HPROGRAM,YRECFM,NFLOOR_LAYER,IRESP)
147   YRECFM='COOL_COIL'
148   CALL READ_SURF(HPROGRAM,YRECFM,CCOOL_COIL,IRESP)
149   YRECFM='HEAT_COIL'
150   CALL READ_SURF(HPROGRAM,YRECFM,CHEAT_COIL,IRESP)
151   YRECFM='AUTOSIZE'
152   CALL READ_SURF(HPROGRAM,YRECFM,LAUTOSIZE,IRESP)
153 ENDIF
154 !
155 !* Case of urban green roofs
156 !
157 IF (LGARDEN) THEN
158   IF (IVERSION<7 .OR.( IVERSION==7 .AND. IBUGFIX<=2)) THEN
159     LGREENROOF = .FALSE.
160   ELSE
161     YRECFM='LGREENROOF'
162     CALL READ_SURF(HPROGRAM,YRECFM,LGREENROOF,IRESP)
163   END IF
164 ENDIF
165 !
166 !
167 !*       3.     Physiographic data fields:
168 !               -------------------------
169 !
170 !* cover classes
171 !
172 ALLOCATE(LCOVER(JPCOVER))
173  CALL READ_LCOVER(HPROGRAM,LCOVER)
174 !
175 ALLOCATE(XCOVER(NDIM,JPCOVER))
176  CALL READ_SURF(HPROGRAM,'COVER',XCOVER(:,:),LCOVER,IRESP,HDIR='H')
177 #ifdef MNH_PARALLEL
178  CALL MPPDB_CHECK_SURFEX3D(XCOVER,"READ_PGD_TEB_n after READ_SURF:XCOVER",PRECISION,ILUOUT, 'TOWN  ',JPCOVER)
179 #endif
180 !
181 !* orography
182 !
183 ALLOCATE(XZS(NDIM))
184 YRECFM='ZS'
185  CALL READ_SURF(HPROGRAM,YRECFM,XZS(:),IRESP)
186 !
187 !
188 !* latitude, longitude 
189 !
190 ALLOCATE(XLAT      (NDIM))
191 ALLOCATE(XLON      (NDIM))
192 ALLOCATE(XMESH_SIZE(NDIM))
193  CALL READ_GRID(HPROGRAM,CGRID,XGRID_PAR,XLAT,XLON,XMESH_SIZE,IRESP)
194 #ifdef MNH_PARALLEL
195  CALL MPPDB_CHECK_SURFEX2D(XLAT,"READ_PGD_TEB_n after READ_GRID:XLAT",PRECISION,ILUOUT,'TOWN  ')
196  CALL MPPDB_CHECK_SURFEX2D(XLON,"READ_PGD_TEB_n after READ_GRID:XLON",PRECISION,ILUOUT,'TOWN  ')
197  CALL MPPDB_CHECK_SURFEX2D(XMESH_SIZE,"READ_PGD_TEB_n after READ_GRID:XMESH_SIZE",PRECISION,ILUOUT,'TOWN  ')
198 #endif
199 !
200 !
201 !-------------------------------------------------------------------------------
202 !
203 !*       4.     Physiographic data fields not to be computed by ecoclimap
204 !               ---------------------------------------------------------
205 !
206  CALL READ_LECOCLIMAP(HPROGRAM,LECOCLIMAP)
207 !
208  CALL READ_PGD_TEB_PAR_n(HPROGRAM,NDIM,'-')
209 IF (LHOOK) CALL DR_HOOK('READ_PGD_TEB_N',1,ZHOOK_HANDLE)
210 !
211 !
212 !------------------------------------------------------------------------------
213 !
214 END SUBROUTINE READ_PGD_TEB_n