[2021] | 1 | module exner_hyb_loc_m |
---|
[1632] | 2 | |
---|
[5281] | 3 | USE comgeom_mod_h |
---|
| 4 | IMPLICIT NONE |
---|
[1632] | 5 | |
---|
[2021] | 6 | contains |
---|
[1632] | 7 | |
---|
[2021] | 8 | SUBROUTINE exner_hyb_loc(ngrid, ps, p, pks,pk,pkf) |
---|
[1632] | 9 | |
---|
[2021] | 10 | ! Auteurs : P.Le Van , Fr. Hourdin . |
---|
| 11 | ! .......... |
---|
| 12 | ! |
---|
| 13 | ! .... ngrid, ps,p sont des argum.d'entree au sous-prog ... |
---|
| 14 | ! .... pks,pk,pkf sont des argum.de sortie au sous-prog ... |
---|
| 15 | ! |
---|
| 16 | ! ************************************************************************ |
---|
[5281] | 17 | ! Calcule la fonction d'Exner pk = Cp * (p/preff) ** kappa , aux milieux des |
---|
[2021] | 18 | ! couches . Pk(l) sera calcule aux milieux des couches l ,entre les |
---|
| 19 | ! pressions p(l) et p(l+1) ,definis aux interfaces des llm couches . |
---|
| 20 | ! ************************************************************************ |
---|
| 21 | ! .. N.B : Au sommet de l'atmosphere, p(llm+1) = 0. , et ps et pks sont |
---|
| 22 | ! la pression et la fonction d'Exner au sol . |
---|
| 23 | ! |
---|
| 24 | ! -------- z |
---|
| 25 | ! A partir des relations ( 1 ) p*dz(pk) = kappa *pk*dz(p) et |
---|
| 26 | ! ( 2 ) pk(l) = alpha(l)+ beta(l)*pk(l-1) |
---|
| 27 | ! ( voir note de Fr.Hourdin ) , |
---|
| 28 | ! |
---|
[5281] | 29 | ! on determine successivement , du haut vers le bas des couches, les |
---|
| 30 | ! coef. alpha(llm),beta(llm) .,.,alpha(l),beta(l),,,alpha(2),beta(2), |
---|
| 31 | ! puis pk(ij,1). Ensuite ,on calcule,du bas vers le haut des couches, |
---|
[2021] | 32 | ! pk(ij,l) donne par la relation (2), pour l = 2 a l = llm . |
---|
| 33 | ! |
---|
| 34 | ! |
---|
| 35 | USE parallel_lmdz |
---|
| 36 | USE mod_filtreg_p |
---|
| 37 | USE write_field_loc |
---|
[2597] | 38 | USE comconst_mod, ONLY: cpp, kappa, r, jmp1 |
---|
[2600] | 39 | USE comvert_mod, ONLY: preff |
---|
[5258] | 40 | USE lmdz_cppkeys_wrapper, ONLY: CPPKEY_DEBUGIO |
---|
[5271] | 41 | USE dimensions_mod, ONLY: iim, jjm, llm, ndm |
---|
[5285] | 42 | USE paramet_mod_h |
---|
[5271] | 43 | IMPLICIT NONE |
---|
[2021] | 44 | ! |
---|
[5271] | 45 | |
---|
[5272] | 46 | |
---|
[1657] | 47 | |
---|
[2021] | 48 | INTEGER ngrid |
---|
| 49 | REAL p(ijb_u:ije_u,llmp1),pk(ijb_u:ije_u,llm) |
---|
| 50 | REAL, optional:: pkf(ijb_u:ije_u,llm) |
---|
| 51 | REAL ps(ijb_u:ije_u),pks(ijb_u:ije_u) |
---|
| 52 | REAL alpha(ijb_u:ije_u,llm),beta(ijb_u:ije_u,llm) |
---|
| 53 | |
---|
| 54 | ! .... variables locales ... |
---|
| 55 | |
---|
| 56 | INTEGER l, ij |
---|
| 57 | REAL unpl2k,dellta |
---|
| 58 | |
---|
| 59 | INTEGER ije,ijb,jje,jjb |
---|
| 60 | logical,save :: firstcall=.true. |
---|
| 61 | !$OMP THREADPRIVATE(firstcall) |
---|
| 62 | character(len=*),parameter :: modname="exner_hyb_loc" |
---|
| 63 | ! |
---|
| 64 | !$OMP BARRIER |
---|
| 65 | |
---|
| 66 | ! Sanity check |
---|
| 67 | if (firstcall) then |
---|
| 68 | ! sanity checks for Shallow Water case (1 vertical layer) |
---|
| 69 | if (llm.eq.1) then |
---|
[1673] | 70 | if (kappa.ne.1) then |
---|
[2021] | 71 | call abort_gcm(modname, & |
---|
| 72 | "kappa!=1 , but running in Shallow Water mode!!",42) |
---|
[1673] | 73 | endif |
---|
| 74 | if (cpp.ne.r) then |
---|
[2021] | 75 | call abort_gcm(modname, & |
---|
| 76 | "cpp!=r , but running in Shallow Water mode!!",42) |
---|
[1673] | 77 | endif |
---|
[2021] | 78 | endif ! of if (llm.eq.1) |
---|
[1673] | 79 | |
---|
[2021] | 80 | firstcall=.false. |
---|
| 81 | endif ! of if (firstcall) |
---|
[1673] | 82 | |
---|
[2021] | 83 | !$OMP BARRIER |
---|
[1673] | 84 | |
---|
[2021] | 85 | ! Specific behaviour for Shallow Water (1 vertical layer) case: |
---|
| 86 | if (llm.eq.1) then |
---|
[1657] | 87 | |
---|
[2021] | 88 | ! Compute pks(:),pk(:),pkf(:) |
---|
| 89 | ijb=ij_begin |
---|
| 90 | ije=ij_end |
---|
| 91 | !$OMP DO SCHEDULE(STATIC) |
---|
| 92 | DO ij=ijb, ije |
---|
| 93 | pks(ij) = (cpp/preff) * ps(ij) |
---|
[1657] | 94 | pk(ij,1) = .5*pks(ij) |
---|
[2021] | 95 | if (present(pkf)) pkf(ij,1)=pk(ij,1) |
---|
| 96 | ENDDO |
---|
| 97 | !$OMP ENDDO |
---|
[1657] | 98 | |
---|
[2021] | 99 | !$OMP BARRIER |
---|
| 100 | if (present(pkf)) then |
---|
| 101 | jjb=jj_begin |
---|
| 102 | jje=jj_end |
---|
| 103 | CALL filtreg_p ( pkf,jjb_u,jje_u,jjb,jje, jmp1, llm, & |
---|
| 104 | 2, 1, .TRUE., 1 ) |
---|
| 105 | end if |
---|
[1657] | 106 | |
---|
[2021] | 107 | ! our work is done, exit routine |
---|
| 108 | return |
---|
| 109 | endif ! of if (llm.eq.1) |
---|
[1657] | 110 | |
---|
[2021] | 111 | ! General case: |
---|
[1632] | 112 | |
---|
[2021] | 113 | unpl2k = 1.+ 2.* kappa |
---|
[1632] | 114 | |
---|
[2021] | 115 | ! ------------- |
---|
| 116 | ! Calcul de pks |
---|
| 117 | ! ------------- |
---|
| 118 | |
---|
| 119 | ijb=ij_begin |
---|
| 120 | ije=ij_end |
---|
| 121 | |
---|
| 122 | !$OMP DO SCHEDULE(STATIC) |
---|
| 123 | DO ij = ijb, ije |
---|
| 124 | pks(ij) = cpp * ( ps(ij)/preff ) ** kappa |
---|
| 125 | ENDDO |
---|
| 126 | !$OMP ENDDO |
---|
| 127 | ! Synchro OPENMP ici |
---|
| 128 | |
---|
| 129 | !$OMP BARRIER |
---|
| 130 | ! |
---|
| 131 | ! |
---|
| 132 | ! .... Calcul des coeff. alpha et beta pour la couche l = llm .. |
---|
| 133 | ! |
---|
| 134 | !$OMP DO SCHEDULE(STATIC) |
---|
| 135 | DO ij = ijb,ije |
---|
[1632] | 136 | alpha(ij,llm) = 0. |
---|
| 137 | beta (ij,llm) = 1./ unpl2k |
---|
[2021] | 138 | ENDDO |
---|
| 139 | !$OMP ENDDO NOWAIT |
---|
| 140 | ! |
---|
| 141 | ! ... Calcul des coeff. alpha et beta pour l = llm-1 a l = 2 ... |
---|
| 142 | ! |
---|
| 143 | DO l = llm -1 , 2 , -1 |
---|
| 144 | ! |
---|
| 145 | !$OMP DO SCHEDULE(STATIC) |
---|
| 146 | DO ij = ijb, ije |
---|
| 147 | dellta = p(ij,l)* unpl2k + p(ij,l+1)* ( beta(ij,l+1)-unpl2k ) |
---|
| 148 | alpha(ij,l) = - p(ij,l+1) / dellta * alpha(ij,l+1) |
---|
| 149 | beta (ij,l) = p(ij,l ) / dellta |
---|
| 150 | ENDDO |
---|
| 151 | !$OMP ENDDO NOWAIT |
---|
| 152 | ENDDO |
---|
[1632] | 153 | |
---|
[2021] | 154 | ! *********************************************************************** |
---|
| 155 | ! ..... Calcul de pk pour la couche 1 , pres du sol .... |
---|
| 156 | ! |
---|
| 157 | !$OMP DO SCHEDULE(STATIC) |
---|
| 158 | DO ij = ijb, ije |
---|
| 159 | pk(ij,1) = ( p(ij,1)*pks(ij) - 0.5*alpha(ij,2)*p(ij,2) ) / & |
---|
| 160 | ( p(ij,1)* (1.+kappa) + 0.5*( beta(ij,2)-unpl2k )* p(ij,2) ) |
---|
| 161 | ENDDO |
---|
| 162 | !$OMP ENDDO NOWAIT |
---|
| 163 | ! |
---|
| 164 | ! ..... Calcul de pk(ij,l) , pour l = 2 a l = llm ........ |
---|
| 165 | ! |
---|
| 166 | DO l = 2, llm |
---|
| 167 | !$OMP DO SCHEDULE(STATIC) |
---|
| 168 | DO ij = ijb, ije |
---|
| 169 | pk(ij,l) = alpha(ij,l) + beta(ij,l) * pk(ij,l-1) |
---|
| 170 | ENDDO |
---|
| 171 | !$OMP ENDDO NOWAIT |
---|
| 172 | ENDDO |
---|
[1632] | 173 | |
---|
[2021] | 174 | if (present(pkf)) then |
---|
| 175 | ! calcul de pkf |
---|
| 176 | |
---|
| 177 | DO l = 1, llm |
---|
| 178 | !$OMP DO SCHEDULE(STATIC) |
---|
| 179 | DO ij = ijb, ije |
---|
| 180 | pkf(ij,l)=pk(ij,l) |
---|
| 181 | ENDDO |
---|
| 182 | !$OMP ENDDO NOWAIT |
---|
| 183 | ENDDO |
---|
| 184 | |
---|
| 185 | !$OMP BARRIER |
---|
| 186 | |
---|
| 187 | jjb=jj_begin |
---|
| 188 | jje=jj_end |
---|
[5258] | 189 | IF (CPPKEY_DEBUGIO) THEN |
---|
[2021] | 190 | call WriteField_u('pkf',pkf) |
---|
[5258] | 191 | END IF |
---|
[2021] | 192 | CALL filtreg_p ( pkf,jjb_u,jje_u,jjb,jje, jmp1, llm, & |
---|
| 193 | 2, 1, .TRUE., 1 ) |
---|
[5258] | 194 | IF (CPPKEY_DEBUGIO) THEN |
---|
[2021] | 195 | call WriteField_u('pkf',pkf) |
---|
[5258] | 196 | END IF |
---|
[2021] | 197 | end if |
---|
[1632] | 198 | |
---|
[2021] | 199 | END SUBROUTINE exner_hyb_loc |
---|
| 200 | |
---|
| 201 | end module exner_hyb_loc_m |
---|