source: LMDZ5/trunk/libf/dynlonlat_phylonlat/phymar/iniphysiq.F90 @ 2346

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

Physics/dynamics separation:

  • remove all references to dimensions.h from physics. nbp_lon (==iim) , nbp_lat (==jjm+1) and nbp_lev (==llm) from mod_grid_phy_lmdz should be used instead.
  • added module regular_lonlat_mod in phy_common to store information about the global (lon-lat) grid cell boundaries and centers.

EM

File size: 7.1 KB
Line 
1!
2! $Id: iniphysiq.F 1403 2010-07-01 09:02:53Z fairhead $
3!
4SUBROUTINE iniphysiq(iim,jjm,nlayer,punjours, pdayref,ptimestep, &
5                     rlatu,rlatv,rlonu,rlonv,aire,cu,cv,         &
6                     prad,pg,pr,pcpp,iflag_phys)
7  USE dimphy, ONLY: klev ! number of atmospheric levels
8  USE mod_grid_phy_lmdz, ONLY: klon_glo ! number of atmospheric columns
9                                        ! (on full grid)
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 comgeomphy, ONLY: initcomgeomphy, &
15                        airephy, & ! physics grid area (m2)
16                        cuphy, & ! cu coeff. (u_covariant = cu * u)
17                        cvphy, & ! cv coeff. (v_covariant = cv * v)
18                        rlond, & ! longitudes
19                        rlatd ! latitudes
20  USE comcstphy, ONLY: rradius, & ! planet radius (m)
21                       rr, & ! recuced gas constant: R/molar mass of atm
22                       rg, & ! gravity
23                       rcpp  ! specific heat of the atmosphere
24!  USE phyaqua_mod, ONLY: iniaqua
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  USE nrtype, ONLY: pi
30  IMPLICIT NONE
31  !
32  !=======================================================================
33  !   Initialisation of the physical constants and some positional and
34  !   geometrical arrays for the physics
35  !=======================================================================
36 
37 
38  include "iniprint.h"
39
40  REAL,INTENT(IN) :: prad ! radius of the planet (m)
41  REAL,INTENT(IN) :: pg ! gravitational acceleration (m/s2)
42  REAL,INTENT(IN) :: pr ! ! reduced gas constant R/mu
43  REAL,INTENT(IN) :: pcpp ! specific heat Cp
44  REAL,INTENT(IN) :: punjours ! length (in s) of a standard day
45  INTEGER, INTENT (IN) :: nlayer ! number of atmospheric layers
46  INTEGER, INTENT (IN) :: iim ! number of atmospheric coulumns along longitudes
47  INTEGER, INTENT (IN) :: jjm  ! number of atompsheric columns along latitudes
48  REAL, INTENT (IN) :: rlatu(jjm+1) ! latitudes of the physics grid
49  REAL, INTENT (IN) :: rlatv(jjm) ! latitude boundaries of the physics grid
50  REAL, INTENT (IN) :: rlonv(iim+1) ! longitudes of the physics grid
51  REAL, INTENT (IN) :: rlonu(iim+1) ! longitude boundaries of the physics grid
52  REAL, INTENT (IN) :: aire(iim+1,jjm+1) ! area of the dynamics grid (m2)
53  REAL, INTENT (IN) :: cu((iim+1)*(jjm+1)) ! cu coeff. (u_covariant = cu * u)
54  REAL, INTENT (IN) :: cv((iim+1)*jjm) ! cv coeff. (v_covariant = cv * v)
55  INTEGER, INTENT (IN) :: pdayref ! reference day of for the simulation
56  REAL,INTENT(IN) :: ptimestep !physics time step (s)
57  INTEGER,INTENT(IN) :: iflag_phys ! type of physics to be called
58
59  INTEGER :: ibegin,iend,offset
60  INTEGER :: i,j
61  CHARACTER (LEN=20) :: modname='iniphysiq'
62  CHARACTER (LEN=80) :: abort_message
63  REAL :: total_area_phy, total_area_dyn
64
65  ! boundaries, on global grid
66  REAL,ALLOCATABLE :: boundslon_reg(:,:)
67  REAL,ALLOCATABLE :: boundslat_reg(:,:)
68
69  ! global array, on full physics grid:
70  REAL,ALLOCATABLE :: latfi(:)
71  REAL,ALLOCATABLE :: lonfi(:)
72  REAL,ALLOCATABLE :: cufi(:)
73  REAL,ALLOCATABLE :: cvfi(:)
74  REAL,ALLOCATABLE :: airefi(:)
75 
76  IF (nlayer.NE.klev) THEN
77    WRITE(lunout,*) 'STOP in ',trim(modname)
78    WRITE(lunout,*) 'Problem with dimensions :'
79    WRITE(lunout,*) 'nlayer     = ',nlayer
80    WRITE(lunout,*) 'klev   = ',klev
81    abort_message = ''
82    CALL abort_gcm (modname,abort_message,1)
83  ENDIF
84
85  ! init regular global longitude-latitude grid points and boundaries
86  ALLOCATE(boundslon_reg(iim,2))
87  ALLOCATE(boundslat_reg(jjm+1,2))
88 
89  DO i=1,iim
90   boundslon_reg(i,east)=rlonu(i)
91   boundslon_reg(i,west)=rlonu(i+1)
92  ENDDO
93
94  boundslat_reg(1,north)= PI/2
95  boundslat_reg(1,south)= rlatv(1)
96  DO j=2,jjm
97   boundslat_reg(j,north)=rlatv(j-1)
98   boundslat_reg(j,south)=rlatv(j)
99  ENDDO
100  boundslat_reg(jjm+1,north)= rlatv(jjm)
101  boundslat_reg(jjm+1,south)= -PI/2
102
103  ! Write values in module regular_lonlat_mod
104  CALL init_regular_lonlat(iim,jjm+1, rlonv(1:iim), rlatu, &
105                           boundslon_reg, boundslat_reg)
106
107  ! Generate global arrays on full physics grid
108  ALLOCATE(latfi(klon_glo),lonfi(klon_glo),cufi(klon_glo),cvfi(klon_glo))
109  ALLOCATE(airefi(klon_glo))
110
111  IF (klon_glo>1) THEN ! general case
112    ! North pole
113    latfi(1)=rlatu(1)
114    lonfi(1)=0.
115    cufi(1) = cu(1)
116    cvfi(1) = cv(1)
117    DO j=2,jjm
118      DO i=1,iim
119        latfi((j-2)*iim+1+i)= rlatu(j)
120        lonfi((j-2)*iim+1+i)= rlonv(i)
121        cufi((j-2)*iim+1+i) = cu((j-1)*iim+1+i)
122        cvfi((j-2)*iim+1+i) = cv((j-1)*iim+1+i)
123      ENDDO
124    ENDDO
125    ! South pole
126    latfi(klon_glo)= rlatu(jjm+1)
127    lonfi(klon_glo)= 0.
128    cufi(klon_glo) = cu((iim+1)*jjm+1)
129    cvfi(klon_glo) = cv((iim+1)*jjm-iim)
130
131    ! build airefi(), mesh area on physics grid
132    CALL gr_dyn_fi(1,iim+1,jjm+1,klon_glo,aire,airefi)
133    ! Poles are single points on physics grid
134    airefi(1)=sum(aire(1:iim,1))
135    airefi(klon_glo)=sum(aire(1:iim,jjm+1))
136
137    ! Sanity check: do total planet area match between physics and dynamics?
138    total_area_dyn=sum(aire(1:iim,1:jjm+1))
139    total_area_phy=sum(airefi(1:klon_glo))
140    IF (total_area_dyn/=total_area_phy) THEN
141      WRITE (lunout, *) 'iniphysiq: planet total surface discrepancy !!!'
142      WRITE (lunout, *) '     in the dynamics total_area_dyn=', total_area_dyn
143      WRITE (lunout, *) '  but in the physics total_area_phy=', total_area_phy
144      IF (abs(total_area_dyn-total_area_phy)>0.00001*total_area_dyn) THEN
145        ! stop here if the relative difference is more than 0.001%
146        abort_message = 'planet total surface discrepancy'
147        CALL abort_gcm(modname, abort_message, 1)
148      ENDIF
149    ENDIF
150  ELSE ! klon_glo==1, running the 1D model
151    ! just copy over input values
152    latfi(1)=rlatu(1)
153    lonfi(1)=rlonv(1)
154    cufi(1)=cu(1)
155    cvfi(1)=cv(1)
156    airefi(1)=aire(1,1)
157  ENDIF ! of IF (klon_glo>1)
158
159!$OMP PARALLEL
160  ! Now generate local lon/lat/cu/cv/area arrays
161  CALL initcomgeomphy
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  rradius=prad
172  rg=pg
173  rr=pr
174  rcpp=pcpp
175
176!$OMP END PARALLEL
177
178!      print*,'ATTENTION !!! TRAVAILLER SUR INIPHYSIQ'
179!      print*,'CONTROLE DES LATITUDES, LONGITUDES, PARAMETRES ...'
180
181! Additional initializations for aquaplanets
182!!$OMP PARALLEL
183!      if (iflag_phys>=100) then
184!        call iniaqua(klon_omp,rlatd,rlond,iflag_phys)
185!      endif
186!!$OMP END PARALLEL
187
188      END
Note: See TracBrowser for help on using the repository browser.