source: LMDZ5/trunk/libf/dynlonlat_phylonlat/phylmd/iniphysiq_mod.F90 @ 2351

Last change on this file since 2351 was 2351, checked in by Ehouarn Millour, 9 years ago

More on physics/dynamics separation and cleanup:

  • Set things up so that all physics-related initializations are done via iniphysiq.
  • Created a "geometry_mod.F90" module in phy_common to store information on the loacl grid (i.e. replaces comgeomphy) and moreover give these variables more obvious names (e.g.: rlond => longitude, rlatd => latitude, airephy => cell_area).
  • removed obsolete comgeomphy.h and comgeomphy.F90

EM

  • 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: 11.3 KB
Line 
1!
2! $Id: iniphysiq_mod.F90 2351 2015-08-25 15:14:59Z emillour $
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  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  CALL init_physics_distribution(regular_lonlat,4, &
112                                 nbp,ii,jj+1,nlayer,communicator)
113  CALL init_interface_dyn_phys
114 
115  ! init regular global longitude-latitude grid points and boundaries
116  ALLOCATE(boundslon_reg(ii,2))
117  ALLOCATE(boundslat_reg(jj+1,2))
118 
119  DO i=1,ii
120   boundslon_reg(i,east)=rlonu(i)
121   boundslon_reg(i,west)=rlonu(i+1)
122  ENDDO
123
124  boundslat_reg(1,north)= PI/2
125  boundslat_reg(1,south)= rlatv(1)
126  DO j=2,jj
127   boundslat_reg(j,north)=rlatv(j-1)
128   boundslat_reg(j,south)=rlatv(j)
129  ENDDO
130  boundslat_reg(jj+1,north)= rlatv(jj)
131  boundslat_reg(jj+1,south)= -PI/2
132
133  ! Write values in module regular_lonlat_mod
134  CALL init_regular_lonlat(ii,jj+1, rlonv(1:ii), rlatu, &
135                           boundslon_reg, boundslat_reg)
136
137  ! Generate global arrays on full physics grid
138  ALLOCATE(latfi_glo(klon_glo),lonfi_glo(klon_glo))
139  ALLOCATE(cufi_glo(klon_glo),cvfi_glo(klon_glo))
140  ALLOCATE(airefi_glo(klon_glo))
141  ALLOCATE(boundslonfi_glo(klon_glo,4))
142  ALLOCATE(boundslatfi_glo(klon_glo,4))
143 
144
145  IF (klon_glo>1) THEN ! general case
146    ! North pole
147    latfi_glo(1)=rlatu(1)
148    lonfi_glo(1)=0.
149    cufi_glo(1) = cu(1)
150    cvfi_glo(1) = cv(1)
151    boundslonfi_glo(1,north_east)=0
152    boundslatfi_glo(1,north_east)=PI/2
153    boundslonfi_glo(1,north_west)=2*PI
154    boundslatfi_glo(1,north_west)=PI/2
155    boundslonfi_glo(1,south_west)=2*PI
156    boundslatfi_glo(1,south_west)=rlatv(1)
157    boundslonfi_glo(1,south_east)=0
158    boundslatfi_glo(1,south_east)=rlatv(1)
159    DO j=2,jj
160      DO i=1,ii
161        k=(j-2)*ii+1+i
162        latfi_glo(k)= rlatu(j)
163        lonfi_glo(k)= rlonv(i)
164        cufi_glo(k) = cu((j-1)*ii+1+i)
165        cvfi_glo(k) = cv((j-1)*ii+1+i)
166        boundslonfi_glo(k,north_east)=rlonu(i)
167        boundslatfi_glo(k,north_east)=rlatv(j-1)
168        boundslonfi_glo(k,north_west)=rlonu(i+1)
169        boundslatfi_glo(k,north_west)=rlatv(j-1)
170        boundslonfi_glo(k,south_west)=rlonu(i+1)
171        boundslatfi_glo(k,south_west)=rlatv(j)
172        boundslonfi_glo(k,south_east)=rlonu(i)
173        boundslatfi_glo(k,south_east)=rlatv(j)
174      ENDDO
175    ENDDO
176    ! South pole
177    latfi_glo(klon_glo)= rlatu(jj+1)
178    lonfi_glo(klon_glo)= 0.
179    cufi_glo(klon_glo) = cu((ii+1)*jj+1)
180    cvfi_glo(klon_glo) = cv((ii+1)*jj-ii)
181    boundslonfi_glo(klon_glo,north_east)= 0
182    boundslatfi_glo(klon_glo,north_east)= rlatv(jj)
183    boundslonfi_glo(klon_glo,north_west)= 2*PI
184    boundslatfi_glo(klon_glo,north_west)= rlatv(jj)
185    boundslonfi_glo(klon_glo,south_west)= 2*PI
186    boundslatfi_glo(klon_glo,south_west)= -PI/2
187    boundslonfi_glo(klon_glo,south_east)= 0
188    boundslatfi_glo(klon_glo,south_east)= -Pi/2
189
190    ! build airefi_glo(), mesh area on physics grid
191    CALL gr_dyn_fi(1,ii+1,jj+1,klon_glo,aire,airefi_glo)
192    ! Poles are single points on physics grid
193    airefi_glo(1)=sum(aire(1:ii,1))
194    airefi_glo(klon_glo)=sum(aire(1:ii,jj+1))
195
196    ! Sanity check: do total planet area match between physics and dynamics?
197    total_area_dyn=sum(aire(1:ii,1:jj+1))
198    total_area_phy=sum(airefi_glo(1:klon_glo))
199    IF (total_area_dyn/=total_area_phy) THEN
200      WRITE (lunout, *) 'iniphysiq: planet total surface discrepancy !!!'
201      WRITE (lunout, *) '     in the dynamics total_area_dyn=', total_area_dyn
202      WRITE (lunout, *) '  but in the physics total_area_phy=', total_area_phy
203      IF (abs(total_area_dyn-total_area_phy)>0.00001*total_area_dyn) THEN
204        ! stop here if the relative difference is more than 0.001%
205        abort_message = 'planet total surface discrepancy'
206        CALL abort_gcm(modname, abort_message, 1)
207      ENDIF
208    ENDIF
209  ELSE ! klon_glo==1, running the 1D model
210    ! just copy over input values
211    latfi_glo(1)=rlatu(1)
212    lonfi_glo(1)=rlonv(1)
213    cufi_glo(1)=cu(1)
214    cvfi_glo(1)=cv(1)
215    airefi_glo(1)=aire(1,1)
216    boundslonfi_glo(1,north_east)=rlonu(1)
217    boundslatfi_glo(1,north_east)=PI/2
218    boundslonfi_glo(1,north_west)=rlonu(2)
219    boundslatfi_glo(1,north_west)=PI/2
220    boundslonfi_glo(1,south_west)=rlonu(2)
221    boundslatfi_glo(1,south_west)=rlatv(1)
222    boundslonfi_glo(1,south_east)=rlonu(1)
223    boundslatfi_glo(1,south_east)=rlatv(1)
224  ENDIF ! of IF (klon_glo>1)
225
226!$OMP PARALLEL DEFAULT(SHARED) COPYIN(/temps/)
227  ! Now generate local lon/lat/cu/cv/area/bounds arrays
228  ALLOCATE(latfi(klon_omp),lonfi(klon_omp),cufi(klon_omp),cvfi(klon_omp))
229  ALLOCATE(airefi(klon_omp))
230  ALLOCATE(boundslonfi(klon_omp,4))
231  ALLOCATE(boundslatfi(klon_omp,4))
232
233
234  offset = klon_mpi_begin - 1
235  airefi(1:klon_omp) = airefi_glo(offset+klon_omp_begin:offset+klon_omp_end)
236  cufi(1:klon_omp) = cufi_glo(offset+klon_omp_begin:offset+klon_omp_end)
237  cvfi(1:klon_omp) = cvfi_glo(offset+klon_omp_begin:offset+klon_omp_end)
238  lonfi(1:klon_omp) = lonfi_glo(offset+klon_omp_begin:offset+klon_omp_end)
239  latfi(1:klon_omp) = latfi_glo(offset+klon_omp_begin:offset+klon_omp_end)
240  boundslonfi(1:klon_omp,:) = boundslonfi_glo(offset+klon_omp_begin:offset+klon_omp_end,:)
241  boundslatfi(1:klon_omp,:) = boundslatfi_glo(offset+klon_omp_begin:offset+klon_omp_end,:)
242
243  ! copy over local grid longitudes and latitudes
244  CALL init_geometry(klon_omp,lonfi,latfi,boundslonfi,boundslatfi, &
245                     airefi,cufi,cvfi)
246
247  ! copy over preff , ap(), bp(), etc
248  CALL init_vertical_layers(nlayer,preff,scaleheight, &
249                            ap,bp,presnivs,pseudoalt)
250
251  ! Initialize physical constants in physics:
252  CALL inifis(punjours,prad,pg,pr,pcpp)
253
254  CALL init_time(annee_ref,day_ref,day_ini,start_time,nday,ptimestep)
255
256  ! Initialize dimphy module
257  CALL Init_dimphy(klon_omp,nlayer)
258
259  ! Copy over "offline" settings
260  CALL init_phystokenc(offline,istphy)
261
262  ! Initialize tracer names, numbers, etc. for physics
263  CALL init_infotrac_phy(nqtot,nqo,nbtr,tname,ttext,type_trac,&
264                         niadv,conv_flg,pbl_flg,solsym,&
265                         nqfils,nqdesc,nqdesc_tot,iqfils,iqpere,&
266                         ok_isotopes,ok_iso_verif,ok_isotrac,&
267                         ok_init_iso,niso_possibles,tnat,&
268                         alpha_ideal,use_iso,iqiso,iso_num,&
269                         iso_indnum,zone_num,phase_num,&
270                         indnum_fn_num,index_trac,&
271                         niso,ntraceurs_zone,ntraciso)
272
273  ! Initializations for Reprobus
274  IF (type_trac == 'repr') THEN
275#ifdef REPROBUS
276    CALL Init_chem_rep_phys(klon_omp,nlayer)
277#endif
278  ENDIF
279
280  ! Additional initializations for aquaplanets
281  IF (iflag_phys>=100) THEN
282    CALL iniaqua(klon_omp,iflag_phys)
283  END IF
284!$OMP END PARALLEL
285
286END SUBROUTINE iniphysiq
287
288END MODULE iniphysiq_mod
Note: See TracBrowser for help on using the repository browser.