1 | ! |
---|
2 | ! $Id: iniphysiq_mod.F90 2355 2015-08-28 11:04:00Z oboucher $ |
---|
3 | ! |
---|
4 | MODULE iniphysiq_mod |
---|
5 | |
---|
6 | CONTAINS |
---|
7 | |
---|
8 | SUBROUTINE iniphysiq(ii,jj,nlayer, & |
---|
9 | nbp, communicator, & |
---|
10 | punjours, pdayref,ptimestep, & |
---|
11 | rlatu,rlatv,rlonu,rlonv,aire,cu,cv, & |
---|
12 | prad,pg,pr,pcpp,iflag_phys) |
---|
13 | USE dimphy, ONLY: init_dimphy |
---|
14 | USE mod_grid_phy_lmdz, ONLY: klon_glo, & ! number of atmospheric columns (on full grid) |
---|
15 | regular_lonlat ! regular longitude-latitude grid type |
---|
16 | USE mod_phys_lmdz_para, ONLY: klon_omp, & ! number of columns (on local omp grid) |
---|
17 | klon_omp_begin, & ! start index of local omp subgrid |
---|
18 | klon_omp_end, & ! end index of local omp subgrid |
---|
19 | klon_mpi_begin ! start indes of columns (on local mpi grid) |
---|
20 | USE geometry_mod, ONLY : init_geometry |
---|
21 | USE vertical_layers_mod, ONLY : init_vertical_layers |
---|
22 | USE infotrac, ONLY: nqtot,nqo,nbtr,tname,ttext,type_trac,& |
---|
23 | niadv,conv_flg,pbl_flg,solsym,& |
---|
24 | nqfils,nqdesc,nqdesc_tot,iqfils,iqpere,& |
---|
25 | ok_isotopes,ok_iso_verif,ok_isotrac,& |
---|
26 | ok_init_iso,niso_possibles,tnat,& |
---|
27 | alpha_ideal,use_iso,iqiso,iso_num,& |
---|
28 | iso_indnum,zone_num,phase_num,& |
---|
29 | indnum_fn_num,index_trac,& |
---|
30 | niso,ntraceurs_zone,ntraciso |
---|
31 | #ifdef REPROBUS |
---|
32 | USE CHEM_REP, ONLY : Init_chem_rep_phys |
---|
33 | #endif |
---|
34 | USE control_mod, ONLY: dayref,anneeref,day_step,nday,offline |
---|
35 | USE inifis_mod, ONLY: inifis |
---|
36 | USE time_phylmdz_mod, ONLY: init_time |
---|
37 | USE infotrac_phy, ONLY: init_infotrac_phy |
---|
38 | USE phystokenc_mod, ONLY: init_phystokenc |
---|
39 | USE phyaqua_mod, ONLY: iniaqua |
---|
40 | USE physics_distribution_mod, ONLY : init_physics_distribution |
---|
41 | USE regular_lonlat_mod, ONLY : init_regular_lonlat, & |
---|
42 | east, west, north, south, & |
---|
43 | north_east, north_west, & |
---|
44 | south_west, south_east |
---|
45 | USE mod_interface_dyn_phys, ONLY : init_interface_dyn_phys |
---|
46 | IMPLICIT NONE |
---|
47 | |
---|
48 | ! ======================================================================= |
---|
49 | ! Initialisation of the physical constants and some positional and |
---|
50 | ! geometrical arrays for the physics |
---|
51 | ! ======================================================================= |
---|
52 | |
---|
53 | include "dimensions.h" |
---|
54 | include "comvert.h" |
---|
55 | include "comconst.h" |
---|
56 | include "iniprint.h" |
---|
57 | include "temps.h" |
---|
58 | include "tracstoke.h" |
---|
59 | |
---|
60 | REAL, INTENT (IN) :: prad ! radius of the planet (m) |
---|
61 | REAL, INTENT (IN) :: pg ! gravitational acceleration (m/s2) |
---|
62 | REAL, INTENT (IN) :: pr ! ! reduced gas constant R/mu |
---|
63 | REAL, INTENT (IN) :: pcpp ! specific heat Cp |
---|
64 | REAL, INTENT (IN) :: punjours ! length (in s) of a standard day |
---|
65 | INTEGER, INTENT (IN) :: nlayer ! number of atmospheric layers |
---|
66 | INTEGER, INTENT (IN) :: ii ! number of atmospheric columns along longitudes |
---|
67 | INTEGER, INTENT (IN) :: jj ! number of atompsheric columns along latitudes |
---|
68 | INTEGER, INTENT(IN) :: nbp ! number of physics columns for this MPI process |
---|
69 | INTEGER, INTENT(IN) :: communicator ! MPI communicator |
---|
70 | REAL, INTENT (IN) :: rlatu(jj+1) ! latitudes of the physics grid |
---|
71 | REAL, INTENT (IN) :: rlatv(jj) ! latitude boundaries of the physics grid |
---|
72 | REAL, INTENT (IN) :: rlonv(ii+1) ! longitudes of the physics grid |
---|
73 | REAL, INTENT (IN) :: rlonu(ii+1) ! longitude boundaries of the physics grid |
---|
74 | REAL, INTENT (IN) :: aire(ii+1,jj+1) ! area of the dynamics grid (m2) |
---|
75 | REAL, INTENT (IN) :: cu((ii+1)*(jj+1)) ! cu coeff. (u_covariant = cu * u) |
---|
76 | REAL, INTENT (IN) :: cv((ii+1)*jj) ! cv coeff. (v_covariant = cv * v) |
---|
77 | INTEGER, INTENT (IN) :: pdayref ! reference day of for the simulation |
---|
78 | REAL, INTENT (IN) :: ptimestep !physics time step (s) |
---|
79 | INTEGER, INTENT (IN) :: iflag_phys ! type of physics to be called |
---|
80 | |
---|
81 | INTEGER :: ibegin, iend, offset |
---|
82 | INTEGER :: i,j,k |
---|
83 | CHARACTER (LEN=20) :: modname = 'iniphysiq' |
---|
84 | CHARACTER (LEN=80) :: abort_message |
---|
85 | REAL :: total_area_phy, total_area_dyn |
---|
86 | |
---|
87 | ! boundaries, on global grid |
---|
88 | REAL,ALLOCATABLE :: boundslon_reg(:,:) |
---|
89 | REAL,ALLOCATABLE :: boundslat_reg(:,:) |
---|
90 | |
---|
91 | ! global array, on full physics grid: |
---|
92 | REAL,ALLOCATABLE :: latfi_glo(:) |
---|
93 | REAL,ALLOCATABLE :: lonfi_glo(:) |
---|
94 | REAL,ALLOCATABLE :: cufi_glo(:) |
---|
95 | REAL,ALLOCATABLE :: cvfi_glo(:) |
---|
96 | REAL,ALLOCATABLE :: airefi_glo(:) |
---|
97 | REAL,ALLOCATABLE :: boundslonfi_glo(:,:) |
---|
98 | REAL,ALLOCATABLE :: boundslatfi_glo(:,:) |
---|
99 | |
---|
100 | ! local arrays, on given MPI/OpenMP domain: |
---|
101 | REAL,ALLOCATABLE,SAVE :: latfi(:) |
---|
102 | REAL,ALLOCATABLE,SAVE :: lonfi(:) |
---|
103 | REAL,ALLOCATABLE,SAVE :: cufi(:) |
---|
104 | REAL,ALLOCATABLE,SAVE :: cvfi(:) |
---|
105 | REAL,ALLOCATABLE,SAVE :: airefi(:) |
---|
106 | REAL,ALLOCATABLE,SAVE :: boundslonfi(:,:) |
---|
107 | REAL,ALLOCATABLE,SAVE :: boundslatfi(:,:) |
---|
108 | !$OMP THREADPRIVATE (latfi,lonfi,cufi,cvfi,airefi,boundslonfi,boundslatfi) |
---|
109 | |
---|
110 | ! Initialize Physics distibution and parameters and interface with dynamics |
---|
111 | IF (ii*jj>1) THEN ! general 3D case |
---|
112 | CALL init_physics_distribution(regular_lonlat,4, & |
---|
113 | nbp,ii,jj+1,nlayer,communicator) |
---|
114 | ELSE ! For 1D model |
---|
115 | CALL init_physics_distribution(regular_lonlat,4, & |
---|
116 | 1,1,1,nlayer,communicator) |
---|
117 | ENDIF |
---|
118 | CALL init_interface_dyn_phys |
---|
119 | |
---|
120 | ! init regular global longitude-latitude grid points and boundaries |
---|
121 | ALLOCATE(boundslon_reg(ii,2)) |
---|
122 | ALLOCATE(boundslat_reg(jj+1,2)) |
---|
123 | |
---|
124 | DO i=1,ii |
---|
125 | boundslon_reg(i,east)=rlonu(i) |
---|
126 | boundslon_reg(i,west)=rlonu(i+1) |
---|
127 | ENDDO |
---|
128 | |
---|
129 | boundslat_reg(1,north)= PI/2 |
---|
130 | boundslat_reg(1,south)= rlatv(1) |
---|
131 | DO j=2,jj |
---|
132 | boundslat_reg(j,north)=rlatv(j-1) |
---|
133 | boundslat_reg(j,south)=rlatv(j) |
---|
134 | ENDDO |
---|
135 | boundslat_reg(jj+1,north)= rlatv(jj) |
---|
136 | boundslat_reg(jj+1,south)= -PI/2 |
---|
137 | |
---|
138 | ! Write values in module regular_lonlat_mod |
---|
139 | CALL init_regular_lonlat(ii,jj+1, rlonv(1:ii), rlatu, & |
---|
140 | boundslon_reg, boundslat_reg) |
---|
141 | |
---|
142 | ! Generate global arrays on full physics grid |
---|
143 | ALLOCATE(latfi_glo(klon_glo),lonfi_glo(klon_glo)) |
---|
144 | ALLOCATE(cufi_glo(klon_glo),cvfi_glo(klon_glo)) |
---|
145 | ALLOCATE(airefi_glo(klon_glo)) |
---|
146 | ALLOCATE(boundslonfi_glo(klon_glo,4)) |
---|
147 | ALLOCATE(boundslatfi_glo(klon_glo,4)) |
---|
148 | |
---|
149 | |
---|
150 | IF (klon_glo>1) THEN ! general case |
---|
151 | ! North pole |
---|
152 | latfi_glo(1)=rlatu(1) |
---|
153 | lonfi_glo(1)=0. |
---|
154 | cufi_glo(1) = cu(1) |
---|
155 | cvfi_glo(1) = cv(1) |
---|
156 | boundslonfi_glo(1,north_east)=0 |
---|
157 | boundslatfi_glo(1,north_east)=PI/2 |
---|
158 | boundslonfi_glo(1,north_west)=2*PI |
---|
159 | boundslatfi_glo(1,north_west)=PI/2 |
---|
160 | boundslonfi_glo(1,south_west)=2*PI |
---|
161 | boundslatfi_glo(1,south_west)=rlatv(1) |
---|
162 | boundslonfi_glo(1,south_east)=0 |
---|
163 | boundslatfi_glo(1,south_east)=rlatv(1) |
---|
164 | DO j=2,jj |
---|
165 | DO i=1,ii |
---|
166 | k=(j-2)*ii+1+i |
---|
167 | latfi_glo(k)= rlatu(j) |
---|
168 | lonfi_glo(k)= rlonv(i) |
---|
169 | cufi_glo(k) = cu((j-1)*ii+1+i) |
---|
170 | cvfi_glo(k) = cv((j-1)*ii+1+i) |
---|
171 | boundslonfi_glo(k,north_east)=rlonu(i) |
---|
172 | boundslatfi_glo(k,north_east)=rlatv(j-1) |
---|
173 | boundslonfi_glo(k,north_west)=rlonu(i+1) |
---|
174 | boundslatfi_glo(k,north_west)=rlatv(j-1) |
---|
175 | boundslonfi_glo(k,south_west)=rlonu(i+1) |
---|
176 | boundslatfi_glo(k,south_west)=rlatv(j) |
---|
177 | boundslonfi_glo(k,south_east)=rlonu(i) |
---|
178 | boundslatfi_glo(k,south_east)=rlatv(j) |
---|
179 | ENDDO |
---|
180 | ENDDO |
---|
181 | ! South pole |
---|
182 | latfi_glo(klon_glo)= rlatu(jj+1) |
---|
183 | lonfi_glo(klon_glo)= 0. |
---|
184 | cufi_glo(klon_glo) = cu((ii+1)*jj+1) |
---|
185 | cvfi_glo(klon_glo) = cv((ii+1)*jj-ii) |
---|
186 | boundslonfi_glo(klon_glo,north_east)= 0 |
---|
187 | boundslatfi_glo(klon_glo,north_east)= rlatv(jj) |
---|
188 | boundslonfi_glo(klon_glo,north_west)= 2*PI |
---|
189 | boundslatfi_glo(klon_glo,north_west)= rlatv(jj) |
---|
190 | boundslonfi_glo(klon_glo,south_west)= 2*PI |
---|
191 | boundslatfi_glo(klon_glo,south_west)= -PI/2 |
---|
192 | boundslonfi_glo(klon_glo,south_east)= 0 |
---|
193 | boundslatfi_glo(klon_glo,south_east)= -Pi/2 |
---|
194 | |
---|
195 | ! build airefi_glo(), mesh area on physics grid |
---|
196 | CALL gr_dyn_fi(1,ii+1,jj+1,klon_glo,aire,airefi_glo) |
---|
197 | ! Poles are single points on physics grid |
---|
198 | airefi_glo(1)=sum(aire(1:ii,1)) |
---|
199 | airefi_glo(klon_glo)=sum(aire(1:ii,jj+1)) |
---|
200 | |
---|
201 | ! Sanity check: do total planet area match between physics and dynamics? |
---|
202 | total_area_dyn=sum(aire(1:ii,1:jj+1)) |
---|
203 | total_area_phy=sum(airefi_glo(1:klon_glo)) |
---|
204 | IF (total_area_dyn/=total_area_phy) THEN |
---|
205 | WRITE (lunout, *) 'iniphysiq: planet total surface discrepancy !!!' |
---|
206 | WRITE (lunout, *) ' in the dynamics total_area_dyn=', total_area_dyn |
---|
207 | WRITE (lunout, *) ' but in the physics total_area_phy=', total_area_phy |
---|
208 | IF (abs(total_area_dyn-total_area_phy)>0.00001*total_area_dyn) THEN |
---|
209 | ! stop here if the relative difference is more than 0.001% |
---|
210 | abort_message = 'planet total surface discrepancy' |
---|
211 | CALL abort_gcm(modname, abort_message, 1) |
---|
212 | ENDIF |
---|
213 | ENDIF |
---|
214 | ELSE ! klon_glo==1, running the 1D model |
---|
215 | ! just copy over input values |
---|
216 | latfi_glo(1)=rlatu(1) |
---|
217 | lonfi_glo(1)=rlonv(1) |
---|
218 | cufi_glo(1)=cu(1) |
---|
219 | cvfi_glo(1)=cv(1) |
---|
220 | airefi_glo(1)=aire(1,1) |
---|
221 | boundslonfi_glo(1,north_east)=rlonu(1) |
---|
222 | boundslatfi_glo(1,north_east)=PI/2 |
---|
223 | boundslonfi_glo(1,north_west)=rlonu(2) |
---|
224 | boundslatfi_glo(1,north_west)=PI/2 |
---|
225 | boundslonfi_glo(1,south_west)=rlonu(2) |
---|
226 | boundslatfi_glo(1,south_west)=rlatv(1) |
---|
227 | boundslonfi_glo(1,south_east)=rlonu(1) |
---|
228 | boundslatfi_glo(1,south_east)=rlatv(1) |
---|
229 | ENDIF ! of IF (klon_glo>1) |
---|
230 | |
---|
231 | !$OMP PARALLEL DEFAULT(SHARED) COPYIN(/temps/) |
---|
232 | ! Now generate local lon/lat/cu/cv/area/bounds arrays |
---|
233 | ALLOCATE(latfi(klon_omp),lonfi(klon_omp),cufi(klon_omp),cvfi(klon_omp)) |
---|
234 | ALLOCATE(airefi(klon_omp)) |
---|
235 | ALLOCATE(boundslonfi(klon_omp,4)) |
---|
236 | ALLOCATE(boundslatfi(klon_omp,4)) |
---|
237 | |
---|
238 | |
---|
239 | offset = klon_mpi_begin - 1 |
---|
240 | airefi(1:klon_omp) = airefi_glo(offset+klon_omp_begin:offset+klon_omp_end) |
---|
241 | cufi(1:klon_omp) = cufi_glo(offset+klon_omp_begin:offset+klon_omp_end) |
---|
242 | cvfi(1:klon_omp) = cvfi_glo(offset+klon_omp_begin:offset+klon_omp_end) |
---|
243 | lonfi(1:klon_omp) = lonfi_glo(offset+klon_omp_begin:offset+klon_omp_end) |
---|
244 | latfi(1:klon_omp) = latfi_glo(offset+klon_omp_begin:offset+klon_omp_end) |
---|
245 | boundslonfi(1:klon_omp,:) = boundslonfi_glo(offset+klon_omp_begin:offset+klon_omp_end,:) |
---|
246 | boundslatfi(1:klon_omp,:) = boundslatfi_glo(offset+klon_omp_begin:offset+klon_omp_end,:) |
---|
247 | |
---|
248 | ! copy over local grid longitudes and latitudes |
---|
249 | CALL init_geometry(klon_omp,lonfi,latfi,boundslonfi,boundslatfi, & |
---|
250 | airefi,cufi,cvfi) |
---|
251 | |
---|
252 | ! copy over preff , ap(), bp(), etc |
---|
253 | CALL init_vertical_layers(nlayer,preff,scaleheight, & |
---|
254 | ap,bp,presnivs,pseudoalt) |
---|
255 | |
---|
256 | ! Initialize physical constants in physics: |
---|
257 | CALL inifis(punjours,prad,pg,pr,pcpp) |
---|
258 | |
---|
259 | CALL init_time(annee_ref,day_ref,day_ini,start_time,nday,ptimestep) |
---|
260 | |
---|
261 | ! Initialize dimphy module (unless in 1D where it has already been done) |
---|
262 | IF (klon_glo>1) CALL Init_dimphy(klon_omp,nlayer) |
---|
263 | |
---|
264 | ! Copy over "offline" settings |
---|
265 | CALL init_phystokenc(offline,istphy) |
---|
266 | |
---|
267 | ! Initialize tracer names, numbers, etc. for physics |
---|
268 | CALL init_infotrac_phy(nqtot,nqo,nbtr,tname,ttext,type_trac,& |
---|
269 | niadv,conv_flg,pbl_flg,solsym,& |
---|
270 | nqfils,nqdesc,nqdesc_tot,iqfils,iqpere,& |
---|
271 | ok_isotopes,ok_iso_verif,ok_isotrac,& |
---|
272 | ok_init_iso,niso_possibles,tnat,& |
---|
273 | alpha_ideal,use_iso,iqiso,iso_num,& |
---|
274 | iso_indnum,zone_num,phase_num,& |
---|
275 | indnum_fn_num,index_trac,& |
---|
276 | niso,ntraceurs_zone,ntraciso) |
---|
277 | |
---|
278 | ! Initializations for Reprobus |
---|
279 | IF (type_trac == 'repr') THEN |
---|
280 | #ifdef REPROBUS |
---|
281 | CALL Init_chem_rep_phys(klon_omp,nlayer) |
---|
282 | #endif |
---|
283 | ENDIF |
---|
284 | |
---|
285 | ! Additional initializations for aquaplanets |
---|
286 | IF (iflag_phys>=100) THEN |
---|
287 | CALL iniaqua(klon_omp,iflag_phys) |
---|
288 | END IF |
---|
289 | !$OMP END PARALLEL |
---|
290 | |
---|
291 | END SUBROUTINE iniphysiq |
---|
292 | |
---|
293 | END MODULE iniphysiq_mod |
---|