source: trunk/LMDZ.MARS/libf/dynlonlat_phylonlat/phymars/iniphysiq_mod.F90 @ 1523

Last change on this file since 1523 was 1523, checked in by emillour, 9 years ago

All models: More updates to make planetary codes (+Earth) setups converge.

  • in dyn3d_common:
  • convmas.F => convmas.F90
  • enercin.F => enercin.F90
  • flumass.F => flumass.F90
  • massbar.F => massbar.F90
  • tourpot.F => tourpot.F90
  • vitvert.F => vitvert.F90
  • in misc:
  • move "q_sat" from "dyn3d_common" to "misc" (in Earth model, it is also called by the physics)
  • move "write_field" from "dyn3d_common" to "misc"(may be called from physics or dynamics and depends on neither).
  • in phy_common:
  • move "write_field_phy" here since it may be called from any physics package)
  • add module "regular_lonlat_mod" to store global information on lon-lat grid
  • in dynlonlat_phylonlat/phy*:
  • turn "iniphysiq.F90" into module "iniphysiq_mod.F90" (and of course adapt gcm.F[90] and 1D models accordingly)

EM

File size: 6.3 KB
Line 
1MODULE iniphysiq_mod
2
3CONTAINS
4
5subroutine iniphysiq(ii,jj,nlayer,punjours, pdayref,ptimestep,           &
6                     rlatu,rlatv,rlonu,rlonv,aire,cu,cv,                 &
7                     prad,pg,pr,pcpp,iflag_phys)
8
9use dimphy, only : klev ! number of atmospheric levels
10use mod_grid_phy_lmdz, only : klon_glo ! number of atmospheric columns
11                                       ! (on full grid)
12use 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
17use 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
23use infotrac, only : nqtot ! number of advected tracers
24use comgeomfi_h, only: ini_fillgeom
25use regular_lonlat_mod, only: init_regular_lonlat, &
26                              east, west, north, south, &
27                              north_east, north_west, &
28                              south_west, south_east
29
30implicit none
31
32include "iniprint.h"
33
34real,intent(in) :: prad ! radius of the planet (m)
35real,intent(in) :: pg ! gravitational acceleration (m/s2)
36real,intent(in) :: pr ! ! reduced gas constant R/mu
37real,intent(in) :: pcpp ! specific heat Cp
38real,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)
40integer,intent(in) :: nlayer ! number of atmospheric layers
41integer,intent(in) :: ii ! number of atmospheric coulumns along longitudes
42integer,intent(in) :: jj  ! number of atompsheric columns along latitudes
43real,intent(in) :: rlatu(jj+1) ! latitudes of the physics grid
44real,intent(in) :: rlatv(jj) ! latitude boundaries of the physics grid
45real,intent(in) :: rlonv(ii+1) ! longitudes of the physics grid
46real,intent(in) :: rlonu(ii+1) ! longitude boundaries of the physics grid
47real,intent(in) :: aire(ii+1,jj+1) ! area of the dynamics grid (m2)
48real,intent(in) :: cu((ii+1)*(jj+1)) ! cu coeff. (u_covariant = cu * u)
49real,intent(in) :: cv((ii+1)*jj) ! cv coeff. (v_covariant = cv * v)
50integer,intent(in) :: pdayref ! reference day of for the simulation
51real,intent(in) :: ptimestep !physics time step (s)
52integer,intent(in) :: iflag_phys ! type of physics to be called
53
54integer :: ibegin,iend,offset
55integer :: i,j
56character(len=20) :: modname='iniphysiq'
57character(len=80) :: abort_message
58real :: total_area_phy, total_area_dyn
59real :: pi
60
61! boundaries, on global grid
62real,allocatable :: boundslon_reg(:,:)
63real,allocatable :: boundslat_reg(:,:)
64
65! global array, on full physics grid:
66real,allocatable :: latfi(:)
67real,allocatable :: lonfi(:)
68real,allocatable :: cufi(:)
69real,allocatable :: cvfi(:)
70real,allocatable :: airefi(:)
71
72pi=2.*asin(1.0)
73
74IF (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)
81ENDIF
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
93ALLOCATE(boundslon_reg(ii,2))
94ALLOCATE(boundslat_reg(jj+1,2))
95 
96DO i=1,ii
97   boundslon_reg(i,east)=rlonu(i)
98   boundslon_reg(i,west)=rlonu(i+1)
99ENDDO
100
101boundslat_reg(1,north)= PI/2
102boundslat_reg(1,south)= rlatv(1)
103DO j=2,jj
104   boundslat_reg(j,north)=rlatv(j-1)
105   boundslat_reg(j,south)=rlatv(j)
106ENDDO
107boundslat_reg(jj+1,north)= rlatv(jj)
108boundslat_reg(jj+1,south)= -PI/2
109
110! Write values in module regular_lonlat_mod
111CALL init_regular_lonlat(ii,jj+1, rlonv(1:ii), rlatu, &
112                         boundslon_reg, boundslat_reg)
113
114! Generate global arrays on full physics grid
115allocate(latfi(klon_glo),lonfi(klon_glo),cufi(klon_glo),cvfi(klon_glo))
116latfi(1)=rlatu(1)
117lonfi(1)=0.
118cufi(1) = cu(1)
119cvfi(1) = cv(1)
120DO 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
127ENDDO
128latfi(klon_glo)= rlatu(jj+1)
129lonfi(klon_glo)= 0.
130cufi(klon_glo) = cu((ii+1)*jj+1)
131cvfi(klon_glo) = cv((ii+1)*jj-ii)
132
133! build airefi(), mesh area on physics grid
134allocate(airefi(klon_glo))
135CALL gr_dyn_fi(1,ii+1,jj+1,klon_glo,aire,airefi)
136! Poles are single points on physics grid
137airefi(1)=sum(aire(1:ii,1))
138airefi(klon_glo)=sum(aire(1:ii,jj+1))
139
140! Sanity check: do total planet area match between physics and dynamics?
141total_area_dyn=sum(aire(1:ii,1:jj+1))
142total_area_phy=sum(airefi(1:klon_glo))
143IF (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
152ENDIF
153
154
155
156!$OMP PARALLEL
157! Now generate local lon/lat/cu/cv/area arrays
158call initcomgeomphy
159
160!!!!$OMP PARALLEL PRIVATE(ibegin,iend)
161!!!$OMP+         SHARED(parea,pcu,pcv,plon,plat)
162     
163offset=klon_mpi_begin-1
164airephy(1:klon_omp)=airefi(offset+klon_omp_begin:offset+klon_omp_end)
165cuphy(1:klon_omp)=cufi(offset+klon_omp_begin:offset+klon_omp_end)
166cvphy(1:klon_omp)=cvfi(offset+klon_omp_begin:offset+klon_omp_end)
167rlond(1:klon_omp)=lonfi(offset+klon_omp_begin:offset+klon_omp_end)
168rlatd(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
172call phys_state_var_init(klon_omp,nlayer,nqtot, &
173                         punjours,ptimestep,prad,pg,pr,pcpp)
174call ini_fillgeom(klon_omp,rlatd,rlond,airephy)
175call conf_phys(klon_omp,nlayer,nqtot)
176
177!$OMP END PARALLEL
178
179
180end subroutine iniphysiq
181
182
183END MODULE iniphysiq_mod
Note: See TracBrowser for help on using the repository browser.