b4d72228e15f797a75ed1e7c3f1caac6a2c7de63
[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
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 IMPLICIT NONE
69 !
70 !*       0.1   Declarations of arguments
71 !              -------------------------
72 !
73  CHARACTER(LEN=6),  INTENT(IN)  :: HPROGRAM ! calling program
74 !
75 !*       0.2   Declarations of local variables
76 !              -------------------------------
77 !
78 INTEGER           :: IRESP          ! Error code after redding
79 !
80  CHARACTER(LEN=LEN_HREC) :: YRECFM         ! Name of the article to be read
81 INTEGER           :: IVERSION
82 INTEGER           :: IBUGFIX
83 !
84 REAL(KIND=JPRB) :: ZHOOK_HANDLE
85 !-------------------------------------------------------------------------------
86 !
87 !* 1D physical dimension
88 !
89 IF (LHOOK) CALL DR_HOOK('READ_PGD_TEB_N',0,ZHOOK_HANDLE)
90 YRECFM='SIZE_TOWN'
91  CALL GET_TYPE_DIM_n('TOWN  ',NDIM)
92 !
93 !*       2.     Other dimension initializations:
94 !               --------------------------------
95 !
96  CALL READ_SURF(HPROGRAM,'VERSION',IVERSION,IRESP)
97  CALL READ_SURF(HPROGRAM,'BUG',IBUGFIX,IRESP)
98 !
99 !* number of TEB patches
100 !
101 IF (IVERSION<7 .OR. IVERSION==7 .AND. IBUGFIX<=2) THEN
102   NTEB_PATCH=1
103 ELSE
104   YRECFM='TEB_PATCH'
105   CALL READ_SURF(HPROGRAM,YRECFM,NTEB_PATCH,IRESP)
106 END IF
107 !
108 !* number of road and roof layers
109 !
110 YRECFM='ROAD_LAYER'
111  CALL READ_SURF(HPROGRAM,YRECFM,NROAD_LAYER,IRESP)
112
113 YRECFM='ROOF_LAYER'
114  CALL READ_SURF(HPROGRAM,YRECFM,NROOF_LAYER,IRESP)
115
116 YRECFM='WALL_LAYER'
117  CALL READ_SURF(HPROGRAM,YRECFM,NWALL_LAYER,IRESP)
118 !
119 !
120 !* type of averaging for Buildings (to allow ascendant compatibility)
121 !* type of Building Energy Model
122 !
123 IF (IVERSION<7 .OR.( IVERSION==7 .AND. IBUGFIX<=2)) THEN
124   CBLD_ATYPE='ARI'
125   CBEM = 'DEF'
126 ELSE
127   YRECFM='BLD_ATYPE'
128   CALL READ_SURF(HPROGRAM,YRECFM,CBLD_ATYPE,IRESP)
129   YRECFM='BEM'
130   CALL READ_SURF(HPROGRAM,YRECFM,CBEM,IRESP)
131 END IF
132 !
133 IF (CBEM=="BEM") THEN
134   YRECFM='FLOOR_LAYER'
135   CALL READ_SURF(HPROGRAM,YRECFM,NFLOOR_LAYER,IRESP)
136   YRECFM='COOL_COIL'
137   CALL READ_SURF(HPROGRAM,YRECFM,CCOOL_COIL,IRESP)
138   YRECFM='HEAT_COIL'
139   CALL READ_SURF(HPROGRAM,YRECFM,CHEAT_COIL,IRESP)
140   YRECFM='AUTOSIZE'
141   CALL READ_SURF(HPROGRAM,YRECFM,LAUTOSIZE,IRESP)
142 ENDIF
143 !
144 !* Case of urban green roofs
145 !
146 IF (LGARDEN) THEN
147   IF (IVERSION<7 .OR.( IVERSION==7 .AND. IBUGFIX<=2)) THEN
148     LGREENROOF = .FALSE.
149   ELSE
150     YRECFM='LGREENROOF'
151     CALL READ_SURF(HPROGRAM,YRECFM,LGREENROOF,IRESP)
152   END IF
153 ENDIF
154 !
155 !
156 !*       3.     Physiographic data fields:
157 !               -------------------------
158 !
159 !* cover classes
160 !
161 ALLOCATE(LCOVER(JPCOVER))
162  CALL READ_LCOVER(HPROGRAM,LCOVER)
163 !
164 ALLOCATE(XCOVER(NDIM,JPCOVER))
165  CALL READ_SURF(HPROGRAM,'COVER',XCOVER(:,:),LCOVER,IRESP,HDIR='H')
166 !
167 !* orography
168 !
169 ALLOCATE(XZS(NDIM))
170 YRECFM='ZS'
171  CALL READ_SURF(HPROGRAM,YRECFM,XZS(:),IRESP)
172 !
173 !
174 !* latitude, longitude 
175 !
176 ALLOCATE(XLAT      (NDIM))
177 ALLOCATE(XLON      (NDIM))
178 ALLOCATE(XMESH_SIZE(NDIM))
179  CALL READ_GRID(HPROGRAM,CGRID,XGRID_PAR,XLAT,XLON,XMESH_SIZE,IRESP)
180 !
181 !
182 !-------------------------------------------------------------------------------
183 !
184 !*       4.     Physiographic data fields not to be computed by ecoclimap
185 !               ---------------------------------------------------------
186 !
187  CALL READ_LECOCLIMAP(HPROGRAM,LECOCLIMAP)
188 !
189  CALL READ_PGD_TEB_PAR_n(HPROGRAM,NDIM,'-')
190 IF (LHOOK) CALL DR_HOOK('READ_PGD_TEB_N',1,ZHOOK_HANDLE)
191 !
192 !
193 !------------------------------------------------------------------------------
194 !
195 END SUBROUTINE READ_PGD_TEB_n