68f0c41ff0618df7ddbf0ce1083be778c467021e
[MNH-git_open_source-lfs.git] / src / SURFEX / pgd_surf_atm.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 PGD_SURF_ATM(HPROGRAM,HFILE,HFILETYPE,OZS)
7 !     ###########################################################
8 !!
9 !!    PURPOSE
10 !!    -------
11 !!   This program prepares the physiographic data fields.
12 !!
13 !!    METHOD
14 !!    ------
15 !!   
16 !!    EXTERNAL
17 !!    --------
18 !!
19 !!
20 !!    IMPLICIT ARGUMENTS
21 !!    ------------------
22 !!
23 !!
24 !!    REFERENCE
25 !!    ---------
26 !!
27 !!    AUTHOR
28 !!    ------
29 !!
30 !!    V. Masson                   Meteo-France
31 !!
32 !!    MODIFICATION
33 !!    ------------
34 !!
35 !!    Original     13/10/03
36 !!      A. Lemonsu      05/2009         Ajout de la clef LGARDEN pour TEB
37 !!      J. Escobar      11/2013         Add USE MODI_READ_NAM_PGD_CHEMISTRY
38 !----------------------------------------------------------------------------
39 !
40 !*    0.     DECLARATION
41 !            -----------
42 !
43 USE MODD_SURF_CONF,       ONLY : CPROGNAME
44 USE MODD_PGD_GRID,        ONLY : LLATLONMASK
45 USE MODD_SURF_ATM_n,      ONLY : CNATURE, CSEA, CWATER, CTOWN,     &
46                                  XSEA, XWATER,                     &
47                                  NDIM_NATURE, NDIM_SEA,            &
48                                  NDIM_TOWN,NDIM_WATER,             &
49                                  LECOCLIMAP, LWATER_TO_NATURE,     &
50                                  LTOWN_TO_ROCK, LGARDEN, NDIM_FULL,&
51                                  NSIZE_FULL
52 USE MODD_SURF_ATM_GRID_n, ONLY : CGRID, XGRID_PAR, NGRID_PAR, XLAT, &
53                                  XLON, XMESH_SIZE, XJPDIR   
54 USE MODD_CH_SURF_n,       ONLY : LCH_EMIS, CCH_EMIS
55 !
56 USE MODI_GET_LUOUT
57 USE MODI_READ_PGD_ARRANGE_COVER
58 USE MODI_READ_PGD_COVER_GARDEN
59 USE MODI_INI_DATA_COVER
60 USE MODI_READ_PGD_SCHEMES
61 USE MODI_READ_NAM_WRITE_COVER_TEX
62 USE MODI_WRITE_COVER_TEX_START
63 USE MODI_WRITE_COVER_TEX_COVER
64 USE MODI_LATLON_GRID
65 USE MODI_PUT_PGD_GRID
66 USE MODI_LATLONMASK
67 USE MODI_PGD_GAUSS_INDEX
68 USE MODI_PGD_FRAC
69 USE MODI_PGD_COVER
70 USE MODI_PGD_OROGRAPHY
71 USE MODI_PGD_NATURE
72 USE MODI_PGD_TOWN
73 USE MODI_PGD_INLAND_WATER
74 USE MODI_PGD_SEA
75 USE MODI_PGD_DUMMY
76 USE MODI_PGD_CHEMISTRY
77 USE MODI_PGD_CHEMISTRY_SNAP
78 USE MODI_WRITE_COVER_TEX_END
79 USE MODI_INIT_READ_DATA_COVER
80 !
81 USE YOMHOOK   ,ONLY : LHOOK,   DR_HOOK
82 USE PARKIND1  ,ONLY : JPRB
83 !
84 USE MODI_READ_NAM_PGD_CHEMISTRY
85 !
86 IMPLICIT NONE
87 !
88 !*    0.1    Declaration of dummy arguments
89 !            ------------------------------
90 !
91  CHARACTER(LEN=6),     INTENT(IN)  :: HPROGRAM ! program calling
92  CHARACTER(LEN=28),    INTENT(IN)  :: HFILE    ! atmospheric file name
93  CHARACTER(LEN=6),     INTENT(IN)  :: HFILETYPE! atmospheric file type
94 LOGICAL,              INTENT(IN)  :: OZS      ! .true. if orography is imposed by atm. model
95 !
96 !*    0.2    Declaration of local variables
97 !            ------------------------------
98 !
99 INTEGER :: ILUOUT ! logical unit of output listing file
100 REAL(KIND=JPRB) :: ZHOOK_HANDLE
101 !------------------------------------------------------------------------------
102 IF (LHOOK) CALL DR_HOOK('PGD_SURF_ATM',0,ZHOOK_HANDLE)
103 CPROGNAME=HPROGRAM
104 !
105  CALL GET_LUOUT(HPROGRAM,ILUOUT)
106 !
107 !*    1.      Set default constant values 
108 !             ---------------------------
109 !
110  CALL READ_PGD_ARRANGE_COVER(HPROGRAM,LWATER_TO_NATURE,LTOWN_TO_ROCK)
111 !
112  CALL READ_PGD_COVER_GARDEN(HPROGRAM,LGARDEN)
113 !
114  CALL INIT_READ_DATA_COVER(HPROGRAM)
115 !
116  CALL INI_DATA_COVER
117 !
118 !*    1.2     surface schemes
119  CALL READ_PGD_SCHEMES(HPROGRAM,CNATURE,CSEA,CTOWN,CWATER)
120 !
121 !*    1.3     prints all parameters in a Latex file
122  CALL READ_NAM_WRITE_COVER_TEX(HPROGRAM)
123 !
124  CALL WRITE_COVER_TEX_START(HPROGRAM)
125  CALL WRITE_COVER_TEX_COVER
126 !-------------------------------------------------------------------------------
127 !
128 !*    2.      Grid
129 !             ----
130 !
131 ALLOCATE(XLAT(NSIZE_FULL))
132 ALLOCATE(XLON(NSIZE_FULL))
133 ALLOCATE(XMESH_SIZE(NSIZE_FULL))
134 ALLOCATE(XJPDIR(NSIZE_FULL))
135  CALL LATLON_GRID(CGRID,NGRID_PAR,NSIZE_FULL,ILUOUT,XGRID_PAR,XLAT,XLON,XMESH_SIZE,XJPDIR)
136 !
137 !
138 !*    2.3     Stores the grid in the module MODD_PGD_GRID
139 !
140  CALL PUT_PGD_GRID(CGRID,NSIZE_FULL,NGRID_PAR,XGRID_PAR)
141 !
142 !*    2.4     mask to limit the number of input data to read
143  CALL LATLONMASK      (CGRID,NGRID_PAR,XGRID_PAR,LLATLONMASK)
144 !
145 !*    2.5     gaussien grid mesh index
146 !
147 IF(CGRID=='GAUSS') CALL PGD_GAUSS_INDEX(HPROGRAM,OZS)
148 !
149 !-------------------------------------------------------------------------------
150 !
151 !*    3.      surface cover
152 !             -------------
153 !
154  CALL PGD_FRAC(HPROGRAM,LECOCLIMAP)
155 IF (LECOCLIMAP) CALL PGD_COVER(HPROGRAM)
156 !
157 !-------------------------------------------------------------------------------
158 !
159 !*    4.      Orography
160 !             ---------
161 !
162  CALL PGD_OROGRAPHY(HPROGRAM,XSEA,XWATER,HFILE,HFILETYPE,OZS)
163 !
164 !_______________________________________________________________________________
165 !
166 !*    5.      Additionnal fields for nature scheme
167 !             ------------------------------------
168 !
169 IF (NDIM_NATURE>0) CALL PGD_NATURE(HPROGRAM,LECOCLIMAP)  
170 !_______________________________________________________________________________
171 !
172 !*    6.      Additionnal fields for town scheme
173 !             ----------------------------------
174 !
175 IF (NDIM_TOWN>0) CALL PGD_TOWN(HPROGRAM,LECOCLIMAP,LGARDEN)  
176 !_______________________________________________________________________________
177 !
178 !*    7.      Additionnal fields for inland water scheme
179 !             ------------------------------------------
180 !
181 IF (NDIM_WATER>0) CALL PGD_INLAND_WATER(HPROGRAM)   
182 !_______________________________________________________________________________
183 !
184 !*    8.      Additionnal fields for sea scheme
185 !             ---------------------------------
186 !
187 IF (NDIM_SEA>0) CALL PGD_SEA(HPROGRAM)  
188 !
189 !_______________________________________________________________________________
190 !
191 !*    9.      Dummy fields
192 !             ------------
193 !
194  CALL PGD_DUMMY(HPROGRAM)
195 !_______________________________________________________________________________
196 !
197 !*   10.      Chemical Emission fields
198 !             ------------------------
199 !
200  CALL READ_NAM_PGD_CHEMISTRY(HPROGRAM,CCH_EMIS)
201 IF (CCH_EMIS=='SNAP') THEN
202   CALL PGD_CHEMISTRY_SNAP(HPROGRAM,LCH_EMIS)
203 ELSE IF (CCH_EMIS=='AGGR') THEN
204   CALL PGD_CHEMISTRY(HPROGRAM,LCH_EMIS)
205 ENDIF
206 !_______________________________________________________________________________
207 !
208 !*   11.     Writing in cover latex file
209 !            ---------------------------
210 !
211  CALL WRITE_COVER_TEX_END(HPROGRAM)
212 IF (LHOOK) CALL DR_HOOK('PGD_SURF_ATM',1,ZHOOK_HANDLE)
213 !_______________________________________________________________________________
214 !
215 END SUBROUTINE PGD_SURF_ATM