source: LMDZ5/trunk/libf/dynlonlat_phylonlat/phylmd/iniphysiq.F90 @ 2315

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

More on physics/dynamics separation: make a vertical_layers_mod module to contain information on the vertical discretization. This module should be used from within the physics (instead of including comvert.h from dynamics).
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
  • Property svn:eol-style set to native
  • Property svn:keywords set to Author Date Id Revision
File size: 5.9 KB
Line 
1
2! $Id: iniphysiq.F90 2315 2015-06-25 15:25:50Z emillour $
3
4
5SUBROUTINE iniphysiq(ii,jj,nlayer,punjours, pdayref,ptimestep,           &
6                     rlatu,rlonv,aire,cu,cv,                             &
7                     prad,pg,pr,pcpp,iflag_phys)
8  USE dimphy, ONLY: klev ! number of atmospheric levels
9  USE mod_grid_phy_lmdz, ONLY: klon_glo ! number of atmospheric columns
10                                        ! (on full grid)
11  USE mod_phys_lmdz_para, ONLY: klon_omp, & ! number of columns (on local omp grid)
12                                klon_omp_begin, & ! start index of local omp subgrid
13                                klon_omp_end, & ! end index of local omp subgrid
14                                klon_mpi_begin ! start indes of columns (on local mpi grid)
15  USE vertical_layers_mod, ONLY : init_vertical_layers
16  USE comgeomphy, ONLY: initcomgeomphy, &
17                        airephy, & ! physics grid area (m2)
18                        cuphy, & ! cu coeff. (u_covariant = cu * u)
19                        cvphy, & ! cv coeff. (v_covariant = cv * v)
20                        rlond, & ! longitudes
21                        rlatd ! latitudes
22  USE inifis_mod, ONLY: inifis
23  USE phyaqua_mod, ONLY: iniaqua
24  IMPLICIT NONE
25
26  ! =======================================================================
27  ! Initialisation of the physical constants and some positional and
28  ! geometrical arrays for the physics
29  ! =======================================================================
30
31  include "dimensions.h"
32  include "comvert.h"
33  include "iniprint.h"
34
35  REAL, INTENT (IN) :: prad ! radius of the planet (m)
36  REAL, INTENT (IN) :: pg ! gravitational acceleration (m/s2)
37  REAL, INTENT (IN) :: pr ! ! reduced gas constant R/mu
38  REAL, INTENT (IN) :: pcpp ! specific heat Cp
39  REAL, INTENT (IN) :: punjours ! length (in s) of a standard day
40  INTEGER, INTENT (IN) :: nlayer ! number of atmospheric layers
41  INTEGER, INTENT (IN) :: ii ! number of atmospheric columns 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) :: rlonv(ii+1) ! longitudes of the physics grid
45  REAL, INTENT (IN) :: aire(ii+1,jj+1) ! area of the dynamics grid (m2)
46  REAL, INTENT (IN) :: cu((ii+1)*(jj+1)) ! cu coeff. (u_covariant = cu * u)
47  REAL, INTENT (IN) :: cv((ii+1)*jj) ! cv coeff. (v_covariant = cv * v)
48  INTEGER, INTENT (IN) :: pdayref ! reference day of for the simulation
49  REAL, INTENT (IN) :: ptimestep !physics time step (s)
50  INTEGER, INTENT (IN) :: iflag_phys ! type of physics to be called
51
52  INTEGER :: ibegin, iend, offset
53  INTEGER :: i,j
54  CHARACTER (LEN=20) :: modname = 'iniphysiq'
55  CHARACTER (LEN=80) :: abort_message
56  REAL :: total_area_phy, total_area_dyn
57
58
59  ! global array, on full physics grid:
60  REAL,ALLOCATABLE :: latfi(:)
61  REAL,ALLOCATABLE :: lonfi(:)
62  REAL,ALLOCATABLE :: cufi(:)
63  REAL,ALLOCATABLE :: cvfi(:)
64  REAL,ALLOCATABLE :: airefi(:)
65
66  IF (nlayer/=klev) THEN
67    WRITE (lunout, *) 'STOP in ', trim(modname)
68    WRITE (lunout, *) 'Problem with dimensions :'
69    WRITE (lunout, *) 'nlayer     = ', nlayer
70    WRITE (lunout, *) 'klev   = ', klev
71    abort_message = ''
72    CALL abort_gcm(modname, abort_message, 1)
73  END IF
74
75  !call init_phys_lmdz(ii,jj+1,llm,1,(/(jj-1)*ii+2/))
76 
77  ! Generate global arrays on full physics grid
78  ALLOCATE(latfi(klon_glo),lonfi(klon_glo),cufi(klon_glo),cvfi(klon_glo))
79  ALLOCATE(airefi(klon_glo))
80
81  IF (klon_glo>1) THEN ! general case
82    ! North pole
83    latfi(1)=rlatu(1)
84    lonfi(1)=0.
85    cufi(1) = cu(1)
86    cvfi(1) = cv(1)
87    DO j=2,jj
88      DO i=1,ii
89        latfi((j-2)*ii+1+i)= rlatu(j)
90        lonfi((j-2)*ii+1+i)= rlonv(i)
91        cufi((j-2)*ii+1+i) = cu((j-1)*(ii+1)+i)
92        cvfi((j-2)*ii+1+i) = cv((j-1)*(ii+1)+i)
93      ENDDO
94    ENDDO
95    ! South pole
96    latfi(klon_glo)= rlatu(jj+1)
97    lonfi(klon_glo)= 0.
98    cufi(klon_glo) = cu((ii+1)*jj+1)
99    cvfi(klon_glo) = cv((ii+1)*jj-ii)
100
101    ! build airefi(), mesh area on physics grid
102    CALL gr_dyn_fi(1,ii+1,jj+1,klon_glo,aire,airefi)
103    ! Poles are single points on physics grid
104    airefi(1)=sum(aire(1:ii,1))
105    airefi(klon_glo)=sum(aire(1:ii,jj+1))
106
107    ! Sanity check: do total planet area match between physics and dynamics?
108    total_area_dyn=sum(aire(1:ii,1:jj+1))
109    total_area_phy=sum(airefi(1:klon_glo))
110    IF (total_area_dyn/=total_area_phy) THEN
111      WRITE (lunout, *) 'iniphysiq: planet total surface discrepancy !!!'
112      WRITE (lunout, *) '     in the dynamics total_area_dyn=', total_area_dyn
113      WRITE (lunout, *) '  but in the physics total_area_phy=', total_area_phy
114      IF (abs(total_area_dyn-total_area_phy)>0.00001*total_area_dyn) THEN
115        ! stop here if the relative difference is more than 0.001%
116        abort_message = 'planet total surface discrepancy'
117        CALL abort_gcm(modname, abort_message, 1)
118      ENDIF
119    ENDIF
120  ELSE ! klon_glo==1, running the 1D model
121    ! just copy over input values
122    latfi(1)=rlatu(1)
123    lonfi(1)=rlonv(1)
124    cufi(1)=cu(1)
125    cvfi(1)=cv(1)
126    airefi(1)=aire(1,1)
127  ENDIF ! of IF (klon_glo>1)
128
129!$OMP PARALLEL
130  ! Initialize physical constants in physics:
131  CALL inifis(punjours,prad,pg,pr,pcpp)
132 
133  ! copy over preff , ap(), bp(), etc
134  CALL init_vertical_layers(nlayer,preff,scaleheight, &
135                            ap,bp,presnivs,pseudoalt)
136
137  ! Now generate local lon/lat/cu/cv/area arrays
138  CALL initcomgeomphy
139
140  offset = klon_mpi_begin - 1
141  airephy(1:klon_omp) = airefi(offset+klon_omp_begin:offset+klon_omp_end)
142  cuphy(1:klon_omp) = cufi(offset+klon_omp_begin:offset+klon_omp_end)
143  cvphy(1:klon_omp) = cvfi(offset+klon_omp_begin:offset+klon_omp_end)
144  rlond(1:klon_omp) = lonfi(offset+klon_omp_begin:offset+klon_omp_end)
145  rlatd(1:klon_omp) = latfi(offset+klon_omp_begin:offset+klon_omp_end)
146
147  ! Additional initializations for aquaplanets
148  IF (iflag_phys>=100) THEN
149    CALL iniaqua(klon_omp, rlatd, rlond, iflag_phys)
150  END IF
151!$OMP END PARALLEL
152
153END SUBROUTINE iniphysiq
Note: See TracBrowser for help on using the repository browser.