1 | MODULE inigeomphy_mod |
---|
2 | |
---|
3 | CONTAINS |
---|
4 | |
---|
5 | SUBROUTINE inigeomphy(iim,jjm,nlayer, & |
---|
6 | nbp, communicator, & |
---|
7 | rlatu,rlatv,rlonu,rlonv,aire,cu,cv) |
---|
8 | USE mod_grid_phy_lmdz, ONLY: klon_glo, & ! number of atmospheric columns (on full grid) |
---|
9 | regular_lonlat ! regular longitude-latitude grid type |
---|
10 | USE mod_phys_lmdz_para, ONLY: klon_omp, & ! number of columns (on local omp grid) |
---|
11 | klon_omp_begin, & ! start index of local omp subgrid |
---|
12 | klon_omp_end, & ! end index of local omp subgrid |
---|
13 | klon_mpi_begin ! start indes of columns (on local mpi grid) |
---|
14 | USE geometry_mod, ONLY : init_geometry |
---|
15 | USE physics_distribution_mod, ONLY : init_physics_distribution |
---|
16 | USE regular_lonlat_mod, ONLY : init_regular_lonlat, & |
---|
17 | east, west, north, south, & |
---|
18 | north_east, north_west, & |
---|
19 | south_west, south_east |
---|
20 | USE mod_interface_dyn_phys, ONLY : init_interface_dyn_phys |
---|
21 | USE nrtype, ONLY: pi |
---|
22 | USE comvert_mod, ONLY: preff, ap, bp, aps, bps, presnivs, & |
---|
23 | scaleheight, pseudoalt |
---|
24 | USE vertical_layers_mod, ONLY: init_vertical_layers |
---|
25 | IMPLICIT NONE |
---|
26 | |
---|
27 | ! ======================================================================= |
---|
28 | ! Initialisation of the physical constants and some positional and |
---|
29 | ! geometrical arrays for the physics |
---|
30 | ! ======================================================================= |
---|
31 | |
---|
32 | include "iniprint.h" |
---|
33 | |
---|
34 | INTEGER, INTENT (IN) :: nlayer ! number of atmospheric layers |
---|
35 | INTEGER, INTENT (IN) :: iim ! number of atmospheric columns along longitudes |
---|
36 | INTEGER, INTENT (IN) :: jjm ! number of atompsheric columns along latitudes |
---|
37 | INTEGER, INTENT(IN) :: nbp ! number of physics columns for this MPI process |
---|
38 | INTEGER, INTENT(IN) :: communicator ! MPI communicator |
---|
39 | REAL, INTENT (IN) :: rlatu(jjm+1) ! latitudes of the physics grid |
---|
40 | REAL, INTENT (IN) :: rlatv(jjm) ! latitude boundaries of the physics grid |
---|
41 | REAL, INTENT (IN) :: rlonv(iim+1) ! longitudes of the physics grid |
---|
42 | REAL, INTENT (IN) :: rlonu(iim+1) ! longitude boundaries of the physics grid |
---|
43 | REAL, INTENT (IN) :: aire(iim+1,jjm+1) ! area of the dynamics grid (m2) |
---|
44 | REAL, INTENT (IN) :: cu((iim+1)*(jjm+1)) ! cu coeff. (u_covariant = cu * u) |
---|
45 | REAL, INTENT (IN) :: cv((iim+1)*jjm) ! cv coeff. (v_covariant = cv * v) |
---|
46 | |
---|
47 | INTEGER :: ibegin, iend, offset |
---|
48 | INTEGER :: i,j,k |
---|
49 | CHARACTER (LEN=20) :: modname = 'inigeomphy' |
---|
50 | CHARACTER (LEN=80) :: abort_message |
---|
51 | REAL :: total_area_phy, total_area_dyn |
---|
52 | |
---|
53 | ! boundaries, on global grid |
---|
54 | REAL,ALLOCATABLE :: boundslon_reg(:,:) |
---|
55 | REAL,ALLOCATABLE :: boundslat_reg(:,:) |
---|
56 | |
---|
57 | ! global array, on full physics grid: |
---|
58 | REAL,ALLOCATABLE :: latfi_glo(:) |
---|
59 | REAL,ALLOCATABLE :: lonfi_glo(:) |
---|
60 | REAL,ALLOCATABLE :: cufi_glo(:) |
---|
61 | REAL,ALLOCATABLE :: cvfi_glo(:) |
---|
62 | REAL,ALLOCATABLE :: airefi_glo(:) |
---|
63 | REAL,ALLOCATABLE :: boundslonfi_glo(:,:) |
---|
64 | REAL,ALLOCATABLE :: boundslatfi_glo(:,:) |
---|
65 | |
---|
66 | ! local arrays, on given MPI/OpenMP domain: |
---|
67 | REAL,ALLOCATABLE,SAVE :: latfi(:) |
---|
68 | REAL,ALLOCATABLE,SAVE :: lonfi(:) |
---|
69 | REAL,ALLOCATABLE,SAVE :: cufi(:) |
---|
70 | REAL,ALLOCATABLE,SAVE :: cvfi(:) |
---|
71 | REAL,ALLOCATABLE,SAVE :: airefi(:) |
---|
72 | REAL,ALLOCATABLE,SAVE :: boundslonfi(:,:) |
---|
73 | REAL,ALLOCATABLE,SAVE :: boundslatfi(:,:) |
---|
74 | INTEGER,ALLOCATABLE,SAVE :: ind_cell_glo_fi(:) |
---|
75 | !$OMP THREADPRIVATE (latfi,lonfi,cufi,cvfi,airefi,boundslonfi,boundslatfi,ind_cell_glo_fi) |
---|
76 | |
---|
77 | ! Initialize Physics distibution and parameters and interface with dynamics |
---|
78 | IF (iim*jjm>1) THEN ! general 3D case |
---|
79 | CALL init_physics_distribution(regular_lonlat,4, & |
---|
80 | nbp,iim,jjm+1,nlayer,communicator) |
---|
81 | ELSE ! For 1D model |
---|
82 | CALL init_physics_distribution(regular_lonlat,4, & |
---|
83 | 1,1,1,nlayer,communicator) |
---|
84 | ENDIF |
---|
85 | CALL init_interface_dyn_phys |
---|
86 | |
---|
87 | ! init regular global longitude-latitude grid points and boundaries |
---|
88 | ALLOCATE(boundslon_reg(iim,2)) |
---|
89 | ALLOCATE(boundslat_reg(jjm+1,2)) |
---|
90 | |
---|
91 | DO i=1,iim |
---|
92 | boundslon_reg(i,east)=rlonu(i) |
---|
93 | boundslon_reg(i,west)=rlonu(i+1) |
---|
94 | ENDDO |
---|
95 | |
---|
96 | boundslat_reg(1,north)= PI/2 |
---|
97 | boundslat_reg(1,south)= rlatv(1) |
---|
98 | DO j=2,jjm |
---|
99 | boundslat_reg(j,north)=rlatv(j-1) |
---|
100 | boundslat_reg(j,south)=rlatv(j) |
---|
101 | ENDDO |
---|
102 | boundslat_reg(jjm+1,north)= rlatv(jjm) |
---|
103 | boundslat_reg(jjm+1,south)= -PI/2 |
---|
104 | |
---|
105 | ! Write values in module regular_lonlat_mod |
---|
106 | CALL init_regular_lonlat(iim,jjm+1, rlonv(1:iim), rlatu, & |
---|
107 | boundslon_reg, boundslat_reg) |
---|
108 | |
---|
109 | ! Generate global arrays on full physics grid |
---|
110 | ALLOCATE(latfi_glo(klon_glo),lonfi_glo(klon_glo)) |
---|
111 | ALLOCATE(cufi_glo(klon_glo),cvfi_glo(klon_glo)) |
---|
112 | ALLOCATE(airefi_glo(klon_glo)) |
---|
113 | ALLOCATE(boundslonfi_glo(klon_glo,4)) |
---|
114 | ALLOCATE(boundslatfi_glo(klon_glo,4)) |
---|
115 | |
---|
116 | IF (klon_glo>1) THEN ! general case |
---|
117 | ! North pole |
---|
118 | latfi_glo(1)=rlatu(1) |
---|
119 | lonfi_glo(1)=0. |
---|
120 | cufi_glo(1) = cu(1) |
---|
121 | cvfi_glo(1) = cv(1) |
---|
122 | boundslonfi_glo(1,north_east)=0 |
---|
123 | boundslatfi_glo(1,north_east)=PI/2 |
---|
124 | boundslonfi_glo(1,north_west)=2*PI |
---|
125 | boundslatfi_glo(1,north_west)=PI/2 |
---|
126 | boundslonfi_glo(1,south_west)=2*PI |
---|
127 | boundslatfi_glo(1,south_west)=rlatv(1) |
---|
128 | boundslonfi_glo(1,south_east)=0 |
---|
129 | boundslatfi_glo(1,south_east)=rlatv(1) |
---|
130 | DO j=2,jjm |
---|
131 | DO i=1,iim |
---|
132 | k=(j-2)*iim+1+i |
---|
133 | latfi_glo(k)= rlatu(j) |
---|
134 | lonfi_glo(k)= rlonv(i) |
---|
135 | cufi_glo(k) = cu((j-1)*(iim+1)+i) |
---|
136 | cvfi_glo(k) = cv((j-1)*(iim+1)+i) |
---|
137 | boundslonfi_glo(k,north_east)=rlonu(i) |
---|
138 | boundslatfi_glo(k,north_east)=rlatv(j-1) |
---|
139 | boundslonfi_glo(k,north_west)=rlonu(i+1) |
---|
140 | boundslatfi_glo(k,north_west)=rlatv(j-1) |
---|
141 | boundslonfi_glo(k,south_west)=rlonu(i+1) |
---|
142 | boundslatfi_glo(k,south_west)=rlatv(j) |
---|
143 | boundslonfi_glo(k,south_east)=rlonu(i) |
---|
144 | boundslatfi_glo(k,south_east)=rlatv(j) |
---|
145 | ENDDO |
---|
146 | ENDDO |
---|
147 | ! South pole |
---|
148 | latfi_glo(klon_glo)= rlatu(jjm+1) |
---|
149 | lonfi_glo(klon_glo)= 0. |
---|
150 | cufi_glo(klon_glo) = cu((iim+1)*jjm+1) |
---|
151 | cvfi_glo(klon_glo) = cv((iim+1)*jjm-iim) |
---|
152 | boundslonfi_glo(klon_glo,north_east)= 0 |
---|
153 | boundslatfi_glo(klon_glo,north_east)= rlatv(jjm) |
---|
154 | boundslonfi_glo(klon_glo,north_west)= 2*PI |
---|
155 | boundslatfi_glo(klon_glo,north_west)= rlatv(jjm) |
---|
156 | boundslonfi_glo(klon_glo,south_west)= 2*PI |
---|
157 | boundslatfi_glo(klon_glo,south_west)= -PI/2 |
---|
158 | boundslonfi_glo(klon_glo,south_east)= 0 |
---|
159 | boundslatfi_glo(klon_glo,south_east)= -Pi/2 |
---|
160 | |
---|
161 | ! build airefi(), mesh area on physics grid |
---|
162 | CALL gr_dyn_fi(1,iim+1,jjm+1,klon_glo,aire,airefi_glo) |
---|
163 | ! Poles are single points on physics grid |
---|
164 | airefi_glo(1)=sum(aire(1:iim,1)) |
---|
165 | airefi_glo(klon_glo)=sum(aire(1:iim,jjm+1)) |
---|
166 | |
---|
167 | ! Sanity check: do total planet area match between physics and dynamics? |
---|
168 | total_area_dyn=sum(aire(1:iim,1:jjm+1)) |
---|
169 | total_area_phy=sum(airefi_glo(1:klon_glo)) |
---|
170 | IF (total_area_dyn/=total_area_phy) THEN |
---|
171 | WRITE (lunout, *) 'inigeomphy: planet total surface discrepancy !!!' |
---|
172 | WRITE (lunout, *) ' in the dynamics total_area_dyn=', total_area_dyn |
---|
173 | WRITE (lunout, *) ' but in the physics total_area_phy=', total_area_phy |
---|
174 | IF (abs(total_area_dyn-total_area_phy)>0.00001*total_area_dyn) THEN |
---|
175 | ! stop here if the relative difference is more than 0.001% |
---|
176 | abort_message = 'planet total surface discrepancy' |
---|
177 | CALL abort_gcm(modname, abort_message, 1) |
---|
178 | ENDIF |
---|
179 | ENDIF |
---|
180 | ELSE ! klon_glo==1, running the 1D model |
---|
181 | ! just copy over input values |
---|
182 | latfi_glo(1)=rlatu(1) |
---|
183 | lonfi_glo(1)=rlonv(1) |
---|
184 | cufi_glo(1)=cu(1) |
---|
185 | cvfi_glo(1)=cv(1) |
---|
186 | airefi_glo(1)=aire(1,1) |
---|
187 | boundslonfi_glo(1,north_east)=rlonu(1) |
---|
188 | boundslatfi_glo(1,north_east)=PI/2 |
---|
189 | boundslonfi_glo(1,north_west)=rlonu(2) |
---|
190 | boundslatfi_glo(1,north_west)=PI/2 |
---|
191 | boundslonfi_glo(1,south_west)=rlonu(2) |
---|
192 | boundslatfi_glo(1,south_west)=rlatv(1) |
---|
193 | boundslonfi_glo(1,south_east)=rlonu(1) |
---|
194 | boundslatfi_glo(1,south_east)=rlatv(1) |
---|
195 | ENDIF ! of IF (klon_glo>1) |
---|
196 | |
---|
197 | !$OMP PARALLEL |
---|
198 | ! Now generate local lon/lat/cu/cv/area/bounds arrays |
---|
199 | ALLOCATE(latfi(klon_omp),lonfi(klon_omp),cufi(klon_omp),cvfi(klon_omp)) |
---|
200 | ALLOCATE(airefi(klon_omp)) |
---|
201 | ALLOCATE(boundslonfi(klon_omp,4)) |
---|
202 | ALLOCATE(boundslatfi(klon_omp,4)) |
---|
203 | ALLOCATE(ind_cell_glo_fi(klon_omp)) |
---|
204 | |
---|
205 | |
---|
206 | offset = klon_mpi_begin - 1 |
---|
207 | airefi(1:klon_omp) = airefi_glo(offset+klon_omp_begin:offset+klon_omp_end) |
---|
208 | cufi(1:klon_omp) = cufi_glo(offset+klon_omp_begin:offset+klon_omp_end) |
---|
209 | cvfi(1:klon_omp) = cvfi_glo(offset+klon_omp_begin:offset+klon_omp_end) |
---|
210 | lonfi(1:klon_omp) = lonfi_glo(offset+klon_omp_begin:offset+klon_omp_end) |
---|
211 | latfi(1:klon_omp) = latfi_glo(offset+klon_omp_begin:offset+klon_omp_end) |
---|
212 | boundslonfi(1:klon_omp,:) = boundslonfi_glo(offset+klon_omp_begin:offset+klon_omp_end,:) |
---|
213 | boundslatfi(1:klon_omp,:) = boundslatfi_glo(offset+klon_omp_begin:offset+klon_omp_end,:) |
---|
214 | ind_cell_glo_fi(1:klon_omp)=(/ (i,i=offset+klon_omp_begin,offset+klon_omp_end) /) |
---|
215 | |
---|
216 | ! copy over local grid longitudes and latitudes |
---|
217 | CALL init_geometry(klon_omp,lonfi,latfi,boundslonfi,boundslatfi, & |
---|
218 | airefi,ind_cell_glo_fi,cufi,cvfi) |
---|
219 | |
---|
220 | ! copy over preff , ap(), bp(), etc |
---|
221 | CALL init_vertical_layers(nlayer,preff,scaleheight, & |
---|
222 | ap,bp,aps,bps,presnivs,pseudoalt) |
---|
223 | |
---|
224 | !$OMP END PARALLEL |
---|
225 | |
---|
226 | |
---|
227 | END SUBROUTINE inigeomphy |
---|
228 | |
---|
229 | END MODULE inigeomphy_mod |
---|