source: LMDZ5/branches/testing/libf/phymar/iniphysiq.F90 @ 2275

Last change on this file since 2275 was 2258, checked in by Laurent Fairhead, 10 years ago

Merged trunk changes 2216:2237 into testing branch

File size: 6.0 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,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  IMPLICIT NONE
26  !
27  !=======================================================================
28  !   Initialisation of the physical constants and some positional and
29  !   geometrical arrays for the physics
30  !=======================================================================
31 
32 
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) :: iim ! number of atmospheric coulumns along longitudes
42  INTEGER, INTENT (IN) :: jjm  ! number of atompsheric columns along latitudes
43  REAL, INTENT (IN) :: rlatu(jjm+1) ! latitudes of the physics grid
44  REAL, INTENT (IN) :: rlonv(iim+1) ! longitudes of the physics grid
45  REAL, INTENT (IN) :: aire(iim+1,jjm+1) ! area of the dynamics grid (m2)
46  REAL, INTENT (IN) :: cu((iim+1)*(jjm+1)) ! cu coeff. (u_covariant = cu * u)
47  REAL, INTENT (IN) :: cv((iim+1)*jjm) ! 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.NE.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  ENDIF
74
75
76  ! Generate global arrays on full physics grid
77  ALLOCATE(latfi(klon_glo),lonfi(klon_glo),cufi(klon_glo),cvfi(klon_glo))
78  ALLOCATE(airefi(klon_glo))
79
80  IF (klon_glo>1) THEN ! general case
81    ! North pole
82    latfi(1)=rlatu(1)
83    lonfi(1)=0.
84    cufi(1) = cu(1)
85    cvfi(1) = cv(1)
86    DO j=2,jjm
87      DO i=1,iim
88        latfi((j-2)*iim+1+i)= rlatu(j)
89        lonfi((j-2)*iim+1+i)= rlonv(i)
90        cufi((j-2)*iim+1+i) = cu((j-1)*iim+1+i)
91        cvfi((j-2)*iim+1+i) = cv((j-1)*iim+1+i)
92      ENDDO
93    ENDDO
94    ! South pole
95    latfi(klon_glo)= rlatu(jjm+1)
96    lonfi(klon_glo)= 0.
97    cufi(klon_glo) = cu((iim+1)*jjm+1)
98    cvfi(klon_glo) = cv((iim+1)*jjm-iim)
99
100    ! build airefi(), mesh area on physics grid
101    CALL gr_dyn_fi(1,iim+1,jjm+1,klon_glo,aire,airefi)
102    ! Poles are single points on physics grid
103    airefi(1)=sum(aire(1:iim,1))
104    airefi(klon_glo)=sum(aire(1:iim,jjm+1))
105
106    ! Sanity check: do total planet area match between physics and dynamics?
107    total_area_dyn=sum(aire(1:iim,1:jjm+1))
108    total_area_phy=sum(airefi(1:klon_glo))
109    IF (total_area_dyn/=total_area_phy) THEN
110      WRITE (lunout, *) 'iniphysiq: planet total surface discrepancy !!!'
111      WRITE (lunout, *) '     in the dynamics total_area_dyn=', total_area_dyn
112      WRITE (lunout, *) '  but in the physics total_area_phy=', total_area_phy
113      IF (abs(total_area_dyn-total_area_phy)>0.00001*total_area_dyn) THEN
114        ! stop here if the relative difference is more than 0.001%
115        abort_message = 'planet total surface discrepancy'
116        CALL abort_gcm(modname, abort_message, 1)
117      ENDIF
118    ENDIF
119  ELSE ! klon_glo==1, running the 1D model
120    ! just copy over input values
121    latfi(1)=rlatu(1)
122    lonfi(1)=rlonv(1)
123    cufi(1)=cu(1)
124    cvfi(1)=cv(1)
125    airefi(1)=aire(1,1)
126  ENDIF ! of IF (klon_glo>1)
127
128!$OMP PARALLEL
129  ! Now generate local lon/lat/cu/cv/area arrays
130  CALL initcomgeomphy
131     
132  offset = klon_mpi_begin - 1
133  airephy(1:klon_omp) = airefi(offset+klon_omp_begin:offset+klon_omp_end)
134  cuphy(1:klon_omp) = cufi(offset+klon_omp_begin:offset+klon_omp_end)
135  cvphy(1:klon_omp) = cvfi(offset+klon_omp_begin:offset+klon_omp_end)
136  rlond(1:klon_omp) = lonfi(offset+klon_omp_begin:offset+klon_omp_end)
137  rlatd(1:klon_omp) = latfi(offset+klon_omp_begin:offset+klon_omp_end)
138
139! copy some fundamental parameters to physics
140  rradius=prad
141  rg=pg
142  rr=pr
143  rcpp=pcpp
144
145!$OMP END PARALLEL
146
147!      print*,'ATTENTION !!! TRAVAILLER SUR INIPHYSIQ'
148!      print*,'CONTROLE DES LATITUDES, LONGITUDES, PARAMETRES ...'
149
150! Additional initializations for aquaplanets
151!$OMP PARALLEL
152      if (iflag_phys>=100) then
153        call iniaqua(klon_omp,rlatd,rlond,iflag_phys)
154      endif
155!$OMP END PARALLEL
156
157      END
Note: See TracBrowser for help on using the repository browser.