1 | MODULE iniphysiq_mod |
---|
2 | |
---|
3 | CONTAINS |
---|
4 | |
---|
5 | subroutine iniphysiq(ii,jj,nlayer,punjours, pdayref,ptimestep, & |
---|
6 | rlatu,rlatv,rlonu,rlonv,aire,cu,cv, & |
---|
7 | prad,pg,pr,pcpp,iflag_phys) |
---|
8 | |
---|
9 | use dimphy, only : klev ! number of atmospheric levels |
---|
10 | use mod_grid_phy_lmdz, only : klon_glo ! number of atmospheric columns |
---|
11 | ! (on full grid) |
---|
12 | use mod_phys_lmdz_para, only : klon_omp, & ! number of columns (on local omp grid) |
---|
13 | klon_omp_begin, & ! start index of local omp subgrid |
---|
14 | klon_omp_end, & ! end index of local omp subgrid |
---|
15 | klon_mpi_begin ! start indes of columns (on local mpi grid) |
---|
16 | |
---|
17 | use comgeomphy, only : initcomgeomphy, & |
---|
18 | airephy, & ! physics grid area (m2) |
---|
19 | cuphy, & ! cu coeff. (u_covariant = cu * u) |
---|
20 | cvphy, & ! cv coeff. (v_covariant = cv * v) |
---|
21 | rlond, & ! longitudes |
---|
22 | rlatd ! latitudes |
---|
23 | use infotrac, only : nqtot ! number of advected tracers |
---|
24 | use comgeomfi_h, only: ini_fillgeom |
---|
25 | use regular_lonlat_mod, only: init_regular_lonlat, & |
---|
26 | east, west, north, south, & |
---|
27 | north_east, north_west, & |
---|
28 | south_west, south_east |
---|
29 | |
---|
30 | implicit none |
---|
31 | |
---|
32 | include "iniprint.h" |
---|
33 | |
---|
34 | real,intent(in) :: prad ! radius of the planet (m) |
---|
35 | real,intent(in) :: pg ! gravitational acceleration (m/s2) |
---|
36 | real,intent(in) :: pr ! ! reduced gas constant R/mu |
---|
37 | real,intent(in) :: pcpp ! specific heat Cp |
---|
38 | real,intent(in) :: punjours ! length (in s) of a standard day |
---|
39 | !integer,intent(in) :: ngrid ! number of horizontal grid points in the physics (full grid) |
---|
40 | integer,intent(in) :: nlayer ! number of atmospheric layers |
---|
41 | integer,intent(in) :: ii ! number of atmospheric coulumns along longitudes |
---|
42 | integer,intent(in) :: jj ! number of atompsheric columns along latitudes |
---|
43 | real,intent(in) :: rlatu(jj+1) ! latitudes of the physics grid |
---|
44 | real,intent(in) :: rlatv(jj) ! latitude boundaries of the physics grid |
---|
45 | real,intent(in) :: rlonv(ii+1) ! longitudes of the physics grid |
---|
46 | real,intent(in) :: rlonu(ii+1) ! longitude boundaries of the physics grid |
---|
47 | real,intent(in) :: aire(ii+1,jj+1) ! area of the dynamics grid (m2) |
---|
48 | real,intent(in) :: cu((ii+1)*(jj+1)) ! cu coeff. (u_covariant = cu * u) |
---|
49 | real,intent(in) :: cv((ii+1)*jj) ! cv coeff. (v_covariant = cv * v) |
---|
50 | integer,intent(in) :: pdayref ! reference day of for the simulation |
---|
51 | real,intent(in) :: ptimestep !physics time step (s) |
---|
52 | integer,intent(in) :: iflag_phys ! type of physics to be called |
---|
53 | |
---|
54 | integer :: ibegin,iend,offset |
---|
55 | integer :: i,j |
---|
56 | character(len=20) :: modname='iniphysiq' |
---|
57 | character(len=80) :: abort_message |
---|
58 | real :: total_area_phy, total_area_dyn |
---|
59 | real :: pi |
---|
60 | |
---|
61 | ! boundaries, on global grid |
---|
62 | real,allocatable :: boundslon_reg(:,:) |
---|
63 | real,allocatable :: boundslat_reg(:,:) |
---|
64 | |
---|
65 | ! global array, on full physics grid: |
---|
66 | real,allocatable :: latfi(:) |
---|
67 | real,allocatable :: lonfi(:) |
---|
68 | real,allocatable :: cufi(:) |
---|
69 | real,allocatable :: cvfi(:) |
---|
70 | real,allocatable :: airefi(:) |
---|
71 | |
---|
72 | pi=2.*asin(1.0) |
---|
73 | |
---|
74 | IF (nlayer.NE.klev) THEN |
---|
75 | write(*,*) 'STOP in ',trim(modname) |
---|
76 | write(*,*) 'Problem with dimensions :' |
---|
77 | write(*,*) 'nlayer = ',nlayer |
---|
78 | write(*,*) 'klev = ',klev |
---|
79 | abort_message = '' |
---|
80 | CALL abort_gcm (modname,abort_message,1) |
---|
81 | ENDIF |
---|
82 | |
---|
83 | !IF (ngrid.NE.klon_glo) THEN |
---|
84 | ! write(*,*) 'STOP in ',trim(modname) |
---|
85 | ! write(*,*) 'Problem with dimensions :' |
---|
86 | ! write(*,*) 'ngrid = ',ngrid |
---|
87 | ! write(*,*) 'klon = ',klon_glo |
---|
88 | ! abort_message = '' |
---|
89 | ! CALL abort_gcm (modname,abort_message,1) |
---|
90 | !ENDIF |
---|
91 | |
---|
92 | ! init regular global longitude-latitude grid points and boundaries |
---|
93 | ALLOCATE(boundslon_reg(ii,2)) |
---|
94 | ALLOCATE(boundslat_reg(jj+1,2)) |
---|
95 | |
---|
96 | DO i=1,ii |
---|
97 | boundslon_reg(i,east)=rlonu(i) |
---|
98 | boundslon_reg(i,west)=rlonu(i+1) |
---|
99 | ENDDO |
---|
100 | |
---|
101 | boundslat_reg(1,north)= PI/2 |
---|
102 | boundslat_reg(1,south)= rlatv(1) |
---|
103 | DO j=2,jj |
---|
104 | boundslat_reg(j,north)=rlatv(j-1) |
---|
105 | boundslat_reg(j,south)=rlatv(j) |
---|
106 | ENDDO |
---|
107 | boundslat_reg(jj+1,north)= rlatv(jj) |
---|
108 | boundslat_reg(jj+1,south)= -PI/2 |
---|
109 | |
---|
110 | ! Write values in module regular_lonlat_mod |
---|
111 | CALL init_regular_lonlat(ii,jj+1, rlonv(1:ii), rlatu, & |
---|
112 | boundslon_reg, boundslat_reg) |
---|
113 | |
---|
114 | ! Generate global arrays on full physics grid |
---|
115 | allocate(latfi(klon_glo),lonfi(klon_glo),cufi(klon_glo),cvfi(klon_glo)) |
---|
116 | latfi(1)=rlatu(1) |
---|
117 | lonfi(1)=0. |
---|
118 | cufi(1) = cu(1) |
---|
119 | cvfi(1) = cv(1) |
---|
120 | DO j=2,jj |
---|
121 | DO i=1,ii |
---|
122 | latfi((j-2)*ii+1+i)= rlatu(j) |
---|
123 | lonfi((j-2)*ii+1+i)= rlonv(i) |
---|
124 | cufi((j-2)*ii+1+i) = cu((j-1)*(ii+1)+i) |
---|
125 | cvfi((j-2)*ii+1+i) = cv((j-1)*(ii+1)+i) |
---|
126 | ENDDO |
---|
127 | ENDDO |
---|
128 | latfi(klon_glo)= rlatu(jj+1) |
---|
129 | lonfi(klon_glo)= 0. |
---|
130 | cufi(klon_glo) = cu((ii+1)*jj+1) |
---|
131 | cvfi(klon_glo) = cv((ii+1)*jj-ii) |
---|
132 | |
---|
133 | ! build airefi(), mesh area on physics grid |
---|
134 | allocate(airefi(klon_glo)) |
---|
135 | CALL gr_dyn_fi(1,ii+1,jj+1,klon_glo,aire,airefi) |
---|
136 | ! Poles are single points on physics grid |
---|
137 | airefi(1)=sum(aire(1:ii,1)) |
---|
138 | airefi(klon_glo)=sum(aire(1:ii,jj+1)) |
---|
139 | |
---|
140 | ! Sanity check: do total planet area match between physics and dynamics? |
---|
141 | total_area_dyn=sum(aire(1:ii,1:jj+1)) |
---|
142 | total_area_phy=sum(airefi(1:klon_glo)) |
---|
143 | IF (total_area_dyn/=total_area_phy) THEN |
---|
144 | WRITE (lunout, *) 'iniphysiq: planet total surface discrepancy !!!' |
---|
145 | WRITE (lunout, *) ' in the dynamics total_area_dyn=', total_area_dyn |
---|
146 | WRITE (lunout, *) ' but in the physics total_area_phy=', total_area_phy |
---|
147 | IF (abs(total_area_dyn-total_area_phy)>0.00001*total_area_dyn) THEN |
---|
148 | ! stop here if the relative difference is more than 0.001% |
---|
149 | abort_message = 'planet total surface discrepancy' |
---|
150 | CALL abort_gcm(modname, abort_message, 1) |
---|
151 | ENDIF |
---|
152 | ENDIF |
---|
153 | |
---|
154 | |
---|
155 | |
---|
156 | !$OMP PARALLEL |
---|
157 | ! Now generate local lon/lat/cu/cv/area arrays |
---|
158 | call initcomgeomphy |
---|
159 | |
---|
160 | !!!!$OMP PARALLEL PRIVATE(ibegin,iend) |
---|
161 | !!!$OMP+ SHARED(parea,pcu,pcv,plon,plat) |
---|
162 | |
---|
163 | offset=klon_mpi_begin-1 |
---|
164 | airephy(1:klon_omp)=airefi(offset+klon_omp_begin:offset+klon_omp_end) |
---|
165 | cuphy(1:klon_omp)=cufi(offset+klon_omp_begin:offset+klon_omp_end) |
---|
166 | cvphy(1:klon_omp)=cvfi(offset+klon_omp_begin:offset+klon_omp_end) |
---|
167 | rlond(1:klon_omp)=lonfi(offset+klon_omp_begin:offset+klon_omp_end) |
---|
168 | rlatd(1:klon_omp)=latfi(offset+klon_omp_begin:offset+klon_omp_end) |
---|
169 | |
---|
170 | ! copy some fundamental parameters to physics |
---|
171 | ! and do some initializations |
---|
172 | call phys_state_var_init(klon_omp,nlayer,nqtot, & |
---|
173 | punjours,ptimestep,prad,pg,pr,pcpp) |
---|
174 | call ini_fillgeom(klon_omp,rlatd,rlond,airephy) |
---|
175 | call conf_phys(klon_omp,nlayer,nqtot) |
---|
176 | |
---|
177 | !$OMP END PARALLEL |
---|
178 | |
---|
179 | |
---|
180 | end subroutine iniphysiq |
---|
181 | |
---|
182 | |
---|
183 | END MODULE iniphysiq_mod |
---|