source: LMDZ6/branches/Amaury_dev/libf/dyn3dmem/caldyn_loc.f90 @ 5172

Last change on this file since 5172 was 5159, checked in by abarral, 5 months ago

Put dimensions.h and paramet.h into modules

  • 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: 5.9 KB
Line 
1! $Id: $
2
3SUBROUTINE caldyn_loc &
4        (itau, ucov, vcov, teta, ps, masse, pk, pkf, phis, &
5        phi, conser, du, dv, dteta, dp, w, pbaru, pbarv, time)
6  USE parallel_lmdz
7  USE Write_Field_loc
8  USE caldyn_mod, ONLY: vcont, ucont, ang, p, massebx, masseby, &
9          vorpot, ecin, bern, massebxy, convm
10  USE comvert_mod, ONLY: ap, bp
11  USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_DEBUGIO
12  USE lmdz_comgeom
13
14  USE lmdz_dimensions, ONLY: iim, jjm, llm, ndm
15  USE lmdz_paramet
16  IMPLICIT NONE
17
18  !=======================================================================
19
20  !  Auteur :  P. Le Van
21
22  !   Objet:
23  !   ------
24
25  !   Calcul des tendances dynamiques.
26
27  ! Modif 04/93 F.Forget
28  !=======================================================================
29
30  !-----------------------------------------------------------------------
31  !   0. Declarations:
32  !   ----------------
33
34
35
36
37  !   Arguments:
38  !   ----------
39
40  LOGICAL, INTENT(IN) :: conser ! triggers printing some diagnostics ! not used
41  INTEGER, INTENT(IN) :: itau ! time step index ! not used
42  REAL, INTENT(IN) :: vcov(ijb_v:ije_v, llm) ! covariant meridional wind
43  REAL, INTENT(IN) :: ucov(ijb_u:ije_u, llm) ! covariant zonal wind
44  REAL, INTENT(IN) :: teta(ijb_u:ije_u, llm) ! potential temperature
45  REAL, INTENT(IN) :: ps(ijb_u:ije_u) ! surface pressure
46  REAL, INTENT(IN) :: phis(ijb_u:ije_u) ! geopotential at the surface
47  REAL, INTENT(IN) :: pk(iip1, jjb_u:jje_u, llm) ! Exner at mid-layer
48  REAL, INTENT(IN) :: pkf(ijb_u:ije_u, llm) ! filtered Exner
49  REAL, INTENT(IN) :: phi(ijb_u:ije_u, llm) ! geopotential
50  REAL, INTENT(OUT) :: masse(ijb_u:ije_u, llm) ! air mass
51  REAL, INTENT(OUT) :: dv(ijb_v:ije_v, llm) ! tendency on vcov
52  REAL, INTENT(OUT) :: du(ijb_u:ije_u, llm) ! tendency on ucov
53  REAL, INTENT(OUT) :: dteta(ijb_u:ije_u, llm) ! tenddency on teta
54  REAL, INTENT(OUT) :: dp(ijb_u:ije_u) ! tendency on ps
55  REAL, INTENT(OUT) :: w(ijb_u:ije_u, llm) ! vertical velocity
56  REAL, INTENT(OUT) :: pbaru(ijb_u:ije_u, llm) ! mass flux in the zonal direction
57  REAL, INTENT(OUT) :: pbarv(ijb_v:ije_v, llm) ! mass flux in the meridional direction
58  REAL, INTENT(IN) :: time ! current time
59
60  !   Local:
61  !   ------
62
63  INTEGER :: ij, l, ijb, ije, ierr
64
65
66  !-----------------------------------------------------------------------
67  !   Compute dynamical tendencies:
68  !--------------------------------
69
70  ! compute contravariant winds ucont() and vcont
71  CALL covcont_loc  (llm, ucov, vcov, ucont, vcont)
72  ! compute pressure p()
73  CALL pression_loc (ip1jmp1, ap, bp, ps, p)
74  !ym      CALL psextbar (   ps   , psexbarxy                          )
75  !$OMP BARRIER
76  ! compute mass in each atmospheric mesh: masse()
77  CALL massdair_loc (p, masse)
78  ! compute X and Y-averages of mass, massebx() and masseby()
79  CALL massbar_loc  (masse, massebx, masseby)
80  ! compute XY-average of mass, massebxy()
81  CALL massbarxy_loc(masse, massebxy)
82  ! compute mass fluxes pbaru() and pbarv()
83  CALL flumass_loc  (massebx, masseby, vcont, ucont, pbaru, pbarv)
84  ! compute dteta() , horizontal converging flux of theta
85  CALL dteta1_loc   (teta, pbaru, pbarv, dteta)
86  ! compute convm(), horizontal converging flux of mass
87  CALL convmas1_loc  (pbaru, pbarv, convm)
88  !$OMP BARRIER
89  CALL convmas2_loc  (convm)
90  !$OMP BARRIER
91  IF (CPPKEY_DEBUGIO) THEN
92    CALL WriteField_u('ucont', ucont)
93    CALL WriteField_v('vcont', vcont)
94    CALL WriteField_u('p', p)
95    CALL WriteField_u('masse', masse)
96    CALL WriteField_u('massebx', massebx)
97    CALL WriteField_v('masseby', masseby)
98    CALL WriteField_v('massebxy', massebxy)
99    CALL WriteField_u('pbaru', pbaru)
100    CALL WriteField_v('pbarv', pbarv)
101    CALL WriteField_u('dteta', dteta)
102    CALL WriteField_u('convm', convm)
103  END IF
104
105  !$OMP BARRIER
106  !$OMP MASTER
107  ijb = ij_begin
108  ije = ij_end
109  ! compute pressure variation due to mass convergence
110  DO ij = ijb, ije
111    dp(ij) = convm(ij, 1) / airesurg(ij)
112  ENDDO
113  !$OMP END MASTER
114  !$OMP BARRIER
115
116  ! compute vertical velocity w()
117  CALL vitvert_loc (convm, w)
118  ! compute potential vorticity vorpot()
119  CALL tourpot_loc (vcov, ucov, massebxy, vorpot)
120  ! compute rotation induced du() and dv()
121  CALL dudv1_loc   (vorpot, pbaru, pbarv, du, dv)
122
123  IF (CPPKEY_DEBUGIO) THEN
124    CALL WriteField_u('w', w)
125    CALL WriteField_v('vorpot', vorpot)
126    CALL WriteField_u('du', du)
127    CALL WriteField_v('dv', dv)
128  END IF
129
130  ! compute kinetic energy ecin()
131  CALL enercin_loc (vcov, ucov, vcont, ucont, ecin)
132  ! compute Bernouilli function bern()
133  CALL bernoui_loc (ip1jmp1, llm, phi, ecin, bern)
134  ! compute and add du() and dv() contributions from Bernouilli and pressure
135  CALL dudv2_loc   (teta, pkf, bern, du, dv)
136
137  IF (CPPKEY_DEBUGIO) THEN
138    CALL WriteField_u('ecin', ecin)
139    CALL WriteField_u('bern', bern)
140    CALL WriteField_u('du', du)
141    CALL WriteField_v('dv', dv)
142    CALL WriteField_u('pkf', pkf)
143  END IF
144
145  ijb = ij_begin - iip1
146  ije = ij_end + iip1
147
148  IF (pole_nord) ijb = ij_begin
149  IF (pole_sud) ije = ij_end
150
151  !$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
152  DO l = 1, llm
153    DO ij = ijb, ije
154      ang(ij, l) = ucov(ij, l) + constang(ij)
155    ENDDO
156  ENDDO
157  !$OMP END DO
158
159  ! compute vertical advection contributions to du(), dv() and dteta()
160  CALL advect_new_loc(ang, vcov, teta, w, massebx, masseby, du, dv, dteta)
161
162  !  WARNING probleme de peridocite de dv sur les PC/linux. Pb d'arrondi
163  ! probablement. Observe sur le code compile avec pgf90 3.0-1
164  ijb = ij_begin
165  ije = ij_end
166  IF (pole_sud) ije = ij_end - iip1
167
168  !$OMP DO SCHEDULE(STATIC,OMP_CHUNK)
169  DO l = 1, llm
170    DO ij = ijb, ije, iip1
171      IF(dv(ij, l)/=dv(ij + iim, l))  THEN
172        ! PRINT *,'!!!ATTENTION!!! probleme de periodicite sur vcov',
173        !    ,   ' dans caldyn'
174        ! PRINT *,' l,  ij = ', l, ij, ij+iim,dv(ij+iim,l),dv(ij,l)
175        dv(ij + iim, l) = dv(ij, l)
176      endif
177    enddo
178  enddo
179  !$OMP END DO NOWAIT
180
181  ! Ehouarn: NB: output of control variables not implemented...
182
183
184END SUBROUTINE caldyn_loc
Note: See TracBrowser for help on using the repository browser.