[1] | 1 | ! |
---|
[1189] | 2 | ! $Id: $ |
---|
[1] | 3 | ! |
---|
| 4 | #undef DEBUG_IO |
---|
| 5 | c#define DEBUG_IO |
---|
| 6 | |
---|
| 7 | SUBROUTINE caldyn_p |
---|
[8] | 8 | $ (itau,ucov,vcov,teta,ps,masse,pk,pkf,tsurpk,phis , |
---|
[1] | 9 | $ phi,conser,du,dv,dteta,dp,w,pbaru,pbarv,time ) |
---|
[1019] | 10 | USE parallel_lmdz |
---|
[1] | 11 | USE Write_Field_p |
---|
[1422] | 12 | USE comvert_mod, ONLY: ap,bp |
---|
[1] | 13 | |
---|
| 14 | IMPLICIT NONE |
---|
| 15 | |
---|
[1189] | 16 | !======================================================================= |
---|
| 17 | ! |
---|
| 18 | ! Auteur : P. Le Van |
---|
| 19 | ! |
---|
| 20 | ! Objet: |
---|
| 21 | ! ------ |
---|
| 22 | ! |
---|
| 23 | ! Calcul des tendances dynamiques. |
---|
| 24 | ! |
---|
| 25 | ! Modif 04/93 F.Forget |
---|
| 26 | !======================================================================= |
---|
[1] | 27 | |
---|
[1189] | 28 | !----------------------------------------------------------------------- |
---|
| 29 | ! 0. Declarations: |
---|
| 30 | ! ---------------- |
---|
[1] | 31 | |
---|
| 32 | #include "dimensions.h" |
---|
| 33 | #include "paramet.h" |
---|
| 34 | #include "comgeom.h" |
---|
| 35 | |
---|
[1189] | 36 | ! Arguments: |
---|
| 37 | ! ---------- |
---|
[1] | 38 | |
---|
[1189] | 39 | LOGICAL,INTENT(IN) :: conser ! triggers printing some diagnostics |
---|
| 40 | INTEGER,INTENT(IN) :: itau ! time step index |
---|
| 41 | REAL,INTENT(IN) :: vcov(ip1jm,llm) ! covariant meridional wind |
---|
| 42 | REAL,INTENT(IN) :: ucov(ip1jmp1,llm) ! covariant zonal wind |
---|
| 43 | REAL,INTENT(IN) :: teta(ip1jmp1,llm) ! potential temperature |
---|
| 44 | REAL,INTENT(IN) :: ps(ip1jmp1) ! surface pressure |
---|
| 45 | REAL,INTENT(IN) :: phis(ip1jmp1) ! geopotential at the surface |
---|
| 46 | REAL,INTENT(IN) :: pk(ip1jmp1,llm) ! Exner at mid-layer |
---|
| 47 | REAL,INTENT(IN) :: pkf(ip1jmp1,llm) ! filtered Exner |
---|
| 48 | REAL,INTENT(IN) :: tsurpk(ip1jmp1,llm) ! cpp * temperature / pk |
---|
| 49 | REAL,INTENT(IN) :: phi(ip1jmp1,llm) ! geopotential |
---|
| 50 | REAL,INTENT(OUT) :: masse(ip1jmp1,llm) ! air mass |
---|
| 51 | REAL,INTENT(OUT) :: dv(ip1jm,llm) ! tendency on vcov |
---|
| 52 | REAL,INTENT(OUT) :: du(ip1jmp1,llm) ! tendency on ucov |
---|
| 53 | REAL,INTENT(OUT) :: dteta(ip1jmp1,llm) ! tenddency on teta |
---|
| 54 | REAL,INTENT(OUT) :: dp(ip1jmp1) ! tendency on ps |
---|
| 55 | REAL,INTENT(OUT) :: w(ip1jmp1,llm) ! vertical velocity |
---|
| 56 | REAL,INTENT(OUT) :: pbaru(ip1jmp1,llm) ! mass flux in the zonal direction |
---|
| 57 | REAL,INTENT(OUT) :: pbarv(ip1jm,llm) ! mass flux in the meridional direction |
---|
| 58 | REAL,INTENT(IN) :: time ! current time |
---|
[1] | 59 | |
---|
[1189] | 60 | ! Local: |
---|
| 61 | ! ------ |
---|
| 62 | |
---|
[1] | 63 | REAL,SAVE :: vcont(ip1jm,llm),ucont(ip1jmp1,llm) |
---|
| 64 | REAL,SAVE :: ang(ip1jmp1,llm) |
---|
| 65 | REAL,SAVE :: p(ip1jmp1,llmp1) |
---|
| 66 | REAL,SAVE :: massebx(ip1jmp1,llm),masseby(ip1jm,llm) |
---|
| 67 | REAL,SAVE :: psexbarxy(ip1jm) |
---|
| 68 | REAL,SAVE :: vorpot(ip1jm,llm) |
---|
| 69 | REAL,SAVE :: ecin(ip1jmp1,llm) |
---|
| 70 | REAL,SAVE :: bern(ip1jmp1,llm) |
---|
| 71 | REAL,SAVE :: massebxy(ip1jm,llm) |
---|
| 72 | REAL,SAVE :: convm(ip1jmp1,llm) |
---|
[8] | 73 | ! REAL,SAVE :: temp(ip1jmp1,llm) |
---|
[1] | 74 | INTEGER ij,l,ijb,ije,ierr |
---|
| 75 | |
---|
[1189] | 76 | !----------------------------------------------------------------------- |
---|
| 77 | ! Compute dynamical tendencies: |
---|
| 78 | !-------------------------------- |
---|
| 79 | |
---|
| 80 | ! compute contravariant winds ucont() and vcont |
---|
[1] | 81 | CALL covcont_p ( llm , ucov , vcov , ucont, vcont ) |
---|
[1189] | 82 | ! compute pressure p() |
---|
[1] | 83 | CALL pression_p ( ip1jmp1, ap , bp , ps , p ) |
---|
| 84 | cym CALL psextbar ( ps , psexbarxy ) |
---|
| 85 | c$OMP BARRIER |
---|
[1189] | 86 | ! compute mass in each atmospheric mesh: masse() |
---|
[1] | 87 | CALL massdair_p ( p , masse ) |
---|
[1189] | 88 | ! compute X and Y-averages of mass, massebx() and masseby() |
---|
[1] | 89 | CALL massbar_p ( masse, massebx , masseby ) |
---|
[1189] | 90 | ! compute XY-average of mass, massebxy() |
---|
[1] | 91 | call massbarxy_p( masse, massebxy ) |
---|
[1189] | 92 | ! compute mass fluxes pbaru() and pbarv() |
---|
[1] | 93 | CALL flumass_p ( massebx, masseby , vcont, ucont ,pbaru, pbarv ) |
---|
[1189] | 94 | ! compute dteta() , horizontal converging flux of theta |
---|
[1] | 95 | CALL dteta1_p ( teta , pbaru , pbarv, dteta ) |
---|
[1189] | 96 | ! compute convm(), horizontal converging flux of mass |
---|
[1] | 97 | CALL convmas1_p ( pbaru, pbarv , convm ) |
---|
| 98 | c$OMP BARRIER |
---|
| 99 | CALL convmas2_p ( convm ) |
---|
| 100 | c$OMP BARRIER |
---|
| 101 | #ifdef DEBUG_IO |
---|
| 102 | c$OMP BARRIER |
---|
| 103 | c$OMP MASTER |
---|
| 104 | call WriteField_p('ucont',reshape(ucont,(/iip1,jmp1,llm/))) |
---|
| 105 | call WriteField_p('vcont',reshape(vcont,(/iip1,jjm,llm/))) |
---|
| 106 | call WriteField_p('p',reshape(p,(/iip1,jmp1,llmp1/))) |
---|
| 107 | call WriteField_p('masse',reshape(masse,(/iip1,jmp1,llm/))) |
---|
| 108 | call WriteField_p('massebx',reshape(massebx,(/iip1,jmp1,llm/))) |
---|
| 109 | call WriteField_p('masseby',reshape(masseby,(/iip1,jjm,llm/))) |
---|
| 110 | call WriteField_p('massebxy',reshape(massebxy,(/iip1,jjm,llm/))) |
---|
| 111 | call WriteField_p('pbaru',reshape(pbaru,(/iip1,jmp1,llm/))) |
---|
| 112 | call WriteField_p('pbarv',reshape(pbarv,(/iip1,jjm,llm/))) |
---|
| 113 | call WriteField_p('dteta',reshape(dteta,(/iip1,jmp1,llm/))) |
---|
| 114 | call WriteField_p('convm',reshape(convm,(/iip1,jmp1,llm/))) |
---|
| 115 | c$OMP END MASTER |
---|
| 116 | c$OMP BARRIER |
---|
| 117 | #endif |
---|
| 118 | |
---|
| 119 | c$OMP BARRIER |
---|
| 120 | c$OMP MASTER |
---|
| 121 | ijb=ij_begin |
---|
| 122 | ije=ij_end |
---|
[1189] | 123 | ! compute pressure variation due to mass convergence |
---|
[1] | 124 | DO ij =ijb, ije |
---|
| 125 | dp( ij ) = convm( ij,1 ) / airesurg( ij ) |
---|
| 126 | ENDDO |
---|
| 127 | c$OMP END MASTER |
---|
| 128 | c$OMP BARRIER |
---|
| 129 | c$OMP FLUSH |
---|
[1189] | 130 | |
---|
| 131 | ! compute vertical velocity w() |
---|
[1] | 132 | CALL vitvert_p ( convm , w ) |
---|
[1189] | 133 | ! compute potential vorticity vorpot() |
---|
[1] | 134 | CALL tourpot_p ( vcov , ucov , massebxy , vorpot ) |
---|
[1189] | 135 | ! compute rotation induced du() and dv() |
---|
[1] | 136 | CALL dudv1_p ( vorpot , pbaru , pbarv , du , dv ) |
---|
| 137 | |
---|
| 138 | #ifdef DEBUG_IO |
---|
| 139 | c$OMP BARRIER |
---|
| 140 | c$OMP MASTER |
---|
| 141 | call WriteField_p('w',reshape(w,(/iip1,jmp1,llm/))) |
---|
| 142 | call WriteField_p('vorpot',reshape(vorpot,(/iip1,jjm,llm/))) |
---|
| 143 | call WriteField_p('du',reshape(du,(/iip1,jmp1,llm/))) |
---|
| 144 | call WriteField_p('dv',reshape(dv,(/iip1,jjm,llm/))) |
---|
| 145 | c$OMP END MASTER |
---|
| 146 | c$OMP BARRIER |
---|
| 147 | #endif |
---|
[1189] | 148 | |
---|
| 149 | ! compute kinetic energy ecin() |
---|
[1] | 150 | CALL enercin_p ( vcov , ucov , vcont , ucont , ecin ) |
---|
[1189] | 151 | ! compute Bernouilli function bern() |
---|
[1] | 152 | CALL bernoui_p ( ip1jmp1, llm , phi , ecin , bern ) |
---|
[1189] | 153 | ! compute and add du() and dv() contributions from Bernouilli and pressure |
---|
[8] | 154 | CALL dudv2_p ( tsurpk , pkf , bern , du , dv ) |
---|
[1] | 155 | |
---|
| 156 | #ifdef DEBUG_IO |
---|
| 157 | c$OMP BARRIER |
---|
| 158 | c$OMP MASTER |
---|
| 159 | call WriteField_p('ecin',reshape(ecin,(/iip1,jmp1,llm/))) |
---|
| 160 | call WriteField_p('bern',reshape(bern,(/iip1,jmp1,llm/))) |
---|
| 161 | call WriteField_p('du',reshape(du,(/iip1,jmp1,llm/))) |
---|
| 162 | call WriteField_p('dv',reshape(dv,(/iip1,jjm,llm/))) |
---|
| 163 | call WriteField_p('pkf',reshape(pkf,(/iip1,jmp1,llm/))) |
---|
| 164 | c$OMP END MASTER |
---|
| 165 | c$OMP BARRIER |
---|
| 166 | #endif |
---|
| 167 | |
---|
| 168 | ijb=ij_begin-iip1 |
---|
| 169 | ije=ij_end+iip1 |
---|
| 170 | |
---|
| 171 | if (pole_nord) ijb=ij_begin |
---|
| 172 | if (pole_sud) ije=ij_end |
---|
| 173 | |
---|
| 174 | c$OMP DO SCHEDULE(STATIC,OMP_CHUNK) |
---|
| 175 | DO l=1,llm |
---|
| 176 | DO ij=ijb,ije |
---|
| 177 | ang(ij,l) = ucov(ij,l) + constang(ij) |
---|
| 178 | ENDDO |
---|
| 179 | ENDDO |
---|
| 180 | c$OMP END DO |
---|
| 181 | |
---|
[1189] | 182 | ! compute vertical advection contributions to du(), dv() and dteta() |
---|
[1] | 183 | CALL advect_new_p(ang,vcov,teta,w,massebx,masseby,du,dv,dteta) |
---|
| 184 | |
---|
| 185 | C WARNING probleme de peridocite de dv sur les PC/linux. Pb d'arrondi |
---|
| 186 | C probablement. Observe sur le code compile avec pgf90 3.0-1 |
---|
| 187 | ijb=ij_begin |
---|
| 188 | ije=ij_end |
---|
| 189 | if (pole_sud) ije=ij_end-iip1 |
---|
| 190 | |
---|
| 191 | c$OMP DO SCHEDULE(STATIC,OMP_CHUNK) |
---|
| 192 | DO l = 1, llm |
---|
| 193 | DO ij = ijb, ije, iip1 |
---|
| 194 | IF( dv(ij,l).NE.dv(ij+iim,l) ) THEN |
---|
| 195 | c PRINT *,'!!!ATTENTION!!! probleme de periodicite sur vcov', |
---|
| 196 | c , ' dans caldyn' |
---|
| 197 | c PRINT *,' l, ij = ', l, ij, ij+iim,dv(ij+iim,l),dv(ij,l) |
---|
| 198 | dv(ij+iim,l) = dv(ij,l) |
---|
| 199 | endif |
---|
| 200 | enddo |
---|
| 201 | enddo |
---|
| 202 | c$OMP END DO NOWAIT |
---|
| 203 | c----------------------------------------------------------------------- |
---|
| 204 | c Sorties eventuelles des variables de controle: |
---|
| 205 | c ---------------------------------------------- |
---|
| 206 | |
---|
| 207 | IF( conser ) THEN |
---|
| 208 | c ym ---> exige communication collective ( aussi dans advect) |
---|
| 209 | CALL sortvarc |
---|
[8] | 210 | $ (itau,ucov,tsurpk,ps,masse,pk,phis,vorpot,phi,bern,dp,time,vcov) |
---|
[1] | 211 | |
---|
| 212 | ENDIF |
---|
| 213 | |
---|
| 214 | END |
---|