source: LMDZ5/trunk/libf/dynlonlat_phylonlat/phydev/iniphysiq_mod.F90 @ 2347

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

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