source: LMDZ5/trunk/libf/dynphy_lonlat/phylmd/iniphysiq_mod.F90 @ 2517

Last change on this file since 2517 was 2457, checked in by acozic, 9 years ago

make some modification to allow ce0l to compile with INCA (and so add tracers in start.nc)

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