[381] | 1 | MODULE physics_dcmip2016_mod |
---|
| 2 | USE ICOSA |
---|
| 3 | PRIVATE |
---|
| 4 | |
---|
| 5 | INTEGER,SAVE :: testcase |
---|
| 6 | !$OMP THREADPRIVATE(testcase) |
---|
| 7 | |
---|
[472] | 8 | TYPE(t_field),SAVE,POINTER :: f_out_i(:) |
---|
| 9 | REAL(rstd),SAVE,POINTER :: out_i(:,:) |
---|
[381] | 10 | |
---|
[472] | 11 | TYPE(t_field),SAVE,POINTER :: f_precl(:) |
---|
| 12 | REAL(rstd),SAVE,ALLOCATABLE :: precl_packed(:) |
---|
| 13 | !$OMP THREADPRIVATE(precl_packed) |
---|
[381] | 14 | |
---|
[472] | 15 | TYPE(t_field),SAVE,POINTER :: f_Q1(:) |
---|
| 16 | TYPE(t_field),SAVE,POINTER :: f_Q2(:) |
---|
| 17 | TYPE(t_field),SAVE,POINTER :: f_PS(:) |
---|
| 18 | TYPE(t_field),SAVE,POINTER :: f_rhodz(:) |
---|
| 19 | TYPE(t_field),SAVE,POINTER :: f_Q1_col_int(:) |
---|
| 20 | TYPE(t_field),SAVE,POINTER :: f_Q2_col_int(:) |
---|
[381] | 21 | PUBLIC :: init_physics, full_physics, write_physics |
---|
| 22 | |
---|
| 23 | INTEGER, PARAMETER :: dry_baroclinic=0 |
---|
[416] | 24 | INTEGER, PARAMETER :: moist_baroclinic_full=1 |
---|
| 25 | INTEGER, PARAMETER :: moist_baroclinic_kessler=2 |
---|
| 26 | INTEGER, PARAMETER :: cyclone=3 |
---|
| 27 | INTEGER, PARAMETER :: supercell=4 |
---|
[381] | 28 | |
---|
[416] | 29 | LOGICAL,SAVE :: PBL ! boundary layer |
---|
| 30 | ! True : George Bryan |
---|
| 31 | ! False : Reed & Jablonowsi |
---|
| 32 | !$OMP THREADPRIVATE(PBL) |
---|
[381] | 33 | CONTAINS |
---|
| 34 | |
---|
| 35 | SUBROUTINE init_physics |
---|
| 36 | USE physics_interface_mod |
---|
[434] | 37 | USE omp_para |
---|
[381] | 38 | IMPLICIT NONE |
---|
| 39 | INTEGER :: ngrid |
---|
| 40 | CHARACTER(LEN=255) :: testcase_str |
---|
| 41 | |
---|
[434] | 42 | testcase_str='undefined' |
---|
[381] | 43 | CALL getin("physics_dcmip2016",testcase_str) |
---|
| 44 | |
---|
| 45 | SELECT CASE (TRIM(testcase_str)) |
---|
| 46 | CASE ('dry_baroclinic') |
---|
| 47 | testcase=dry_baroclinic |
---|
[416] | 48 | CASE ('moist_baroclinic_full') |
---|
| 49 | testcase=moist_baroclinic_full |
---|
| 50 | CASE ('moist_baroclinic_kessler') |
---|
| 51 | testcase=moist_baroclinic_kessler |
---|
[381] | 52 | CASE ('cyclone') |
---|
| 53 | testcase=cyclone |
---|
| 54 | CASE ('supercell') |
---|
| 55 | testcase=supercell |
---|
| 56 | CASE DEFAULT |
---|
| 57 | PRINT*, 'Bad selector for dcmip2016 test case <', testcase_str, & |
---|
[434] | 58 | '> options are <dry_baroclinic>, <moist_baroclinic_full>, <moist_baroclinic_kessler>, <cyclone>, <supercell>' |
---|
[381] | 59 | STOP |
---|
| 60 | END SELECT |
---|
| 61 | |
---|
[416] | 62 | PBL=.FALSE. |
---|
| 63 | CALL getin("physics_dcmip2016_PBL",PBL) |
---|
[434] | 64 | IF(is_master) THEN |
---|
| 65 | IF(PBL) THEN |
---|
| 66 | PRINT *, 'PBL=.TRUE., Bryan PBL activated' |
---|
| 67 | ELSE |
---|
| 68 | PRINT *, 'PBL=.FALSE., Reed & Jablonowski PBL activated' |
---|
| 69 | END IF |
---|
| 70 | END IF |
---|
[381] | 71 | |
---|
| 72 | ngrid = physics_inout%ngrid |
---|
| 73 | ! Input |
---|
| 74 | ALLOCATE(physics_inout%Ai(ngrid)) |
---|
| 75 | ALLOCATE(physics_inout%lon(ngrid)) |
---|
| 76 | ALLOCATE(physics_inout%lat(ngrid)) |
---|
| 77 | ALLOCATE(physics_inout%phis(ngrid)) |
---|
| 78 | ALLOCATE(physics_inout%p(ngrid,llm+1)) |
---|
| 79 | ALLOCATE(physics_inout%pk(ngrid,llm)) |
---|
| 80 | ALLOCATE(physics_inout%Temp(ngrid,llm)) |
---|
| 81 | ALLOCATE(physics_inout%ulon(ngrid,llm)) |
---|
| 82 | ALLOCATE(physics_inout%ulat(ngrid,llm)) |
---|
| 83 | ALLOCATE(physics_inout%q(ngrid,llm,nqtot)) |
---|
| 84 | ! Output (tendencies) |
---|
| 85 | ALLOCATE(physics_inout%dTemp(ngrid,llm)) |
---|
| 86 | ALLOCATE(physics_inout%dulon(ngrid,llm)) |
---|
| 87 | ALLOCATE(physics_inout%dulat(ngrid,llm)) |
---|
| 88 | ALLOCATE(physics_inout%dq(ngrid,llm,nqtot)) |
---|
| 89 | ! Physics-specific data |
---|
| 90 | ALLOCATE(precl_packed(ngrid)) |
---|
| 91 | CALL allocate_field(f_precl, field_t,type_real) |
---|
[430] | 92 | CALL allocate_field(f_Q1, field_t,type_real,llm) |
---|
| 93 | CALL allocate_field(f_Q2, field_t,type_real,llm) |
---|
| 94 | CALL allocate_field(f_PS, field_t,type_real) |
---|
| 95 | CALL allocate_field(f_rhodz, field_t,type_real,llm) |
---|
| 96 | CALL allocate_field(f_Q1_col_int, field_t,type_real) |
---|
| 97 | CALL allocate_field(f_Q2_col_int, field_t,type_real) |
---|
[381] | 98 | |
---|
| 99 | PRINT *, 'init_physics_new', SIZE(physics_inout%Ai) |
---|
| 100 | END SUBROUTINE init_physics |
---|
| 101 | |
---|
| 102 | SUBROUTINE full_physics |
---|
| 103 | USE physics_interface_mod |
---|
| 104 | CALL compute_physics(physics_inout%ngrid, physics_inout%dt_phys, & |
---|
| 105 | physics_inout%lon, physics_inout%lat, physics_inout%p, physics_inout%pk, physics_inout%Temp, & |
---|
| 106 | physics_inout%ulon, physics_inout%ulat, physics_inout%q(:,:,1:5), & |
---|
| 107 | physics_inout%dTemp, physics_inout%dulon, physics_inout%dulat, & |
---|
| 108 | physics_inout%dq(:,:,1:5), precl_packed) |
---|
| 109 | END SUBROUTINE full_physics |
---|
| 110 | |
---|
| 111 | SUBROUTINE write_physics |
---|
| 112 | USE output_field_mod |
---|
| 113 | USE physics_interface_mod |
---|
[430] | 114 | use disvert_mod |
---|
| 115 | REAL(rstd), POINTER :: Q1(:,:) |
---|
| 116 | REAL(rstd), POINTER :: Q2(:,:) |
---|
| 117 | REAL(rstd), POINTER :: PS(:) |
---|
| 118 | REAL(rstd), POINTER :: rhodz(:,:) |
---|
| 119 | REAL(rstd), POINTER :: Q1_col_int(:) |
---|
| 120 | REAL(rstd), POINTER :: Q2_col_int(:) |
---|
| 121 | |
---|
| 122 | |
---|
[381] | 123 | CALL unpack_field(f_precl, precl_packed) |
---|
| 124 | CALL output_field("precl",f_precl) |
---|
[430] | 125 | |
---|
| 126 | CALL unpack_field(f_Q1,physics_inout%q(:,:,4)) |
---|
| 127 | CALL unpack_field(f_Q2,physics_inout%q(:,:,5)) |
---|
| 128 | CALL unpack_field(f_ps,physics_inout%p(:,1)) |
---|
| 129 | |
---|
| 130 | DO ind=1,ndomain |
---|
| 131 | IF (.NOT. assigned_domain(ind)) CYCLE |
---|
| 132 | Q1=f_Q1(ind) |
---|
| 133 | Q2=f_Q2(ind) |
---|
| 134 | Q1_col_int=f_Q1_col_int(ind) |
---|
| 135 | Q2_col_int=f_Q2_col_int(ind) |
---|
| 136 | PS=f_PS(ind) |
---|
| 137 | rhodz=f_rhodz(ind) |
---|
| 138 | DO l=1,llm |
---|
| 139 | rhodz(:,l)= ( ap(l)-ap(l+1) + (bp(l)-bp(l+1))*ps(:) )/g |
---|
| 140 | ENDDO |
---|
| 141 | Q1_col_int=SUM(Q1*rhodz,2)/SUM(rhodz,2) |
---|
| 142 | Q2_col_int=SUM(Q2*rhodz,2)/SUM(rhodz,2) |
---|
| 143 | ENDDO |
---|
| 144 | |
---|
| 145 | CALL output_field("Q1_col_int",f_Q1_col_int) |
---|
| 146 | CALL output_field("Q2_col_int",f_Q2_col_int) |
---|
| 147 | |
---|
[381] | 148 | END SUBROUTINE write_physics |
---|
| 149 | |
---|
| 150 | SUBROUTINE compute_physics(ngrid,dt_phys,lon, lat, p, pk, Temp,u,v,q, dTemp,du,dv,dq, precl) |
---|
| 151 | USE icosa |
---|
| 152 | USE dcmip2016_simple_physics_mod |
---|
| 153 | USE dcmip2016_kessler_physic_mod |
---|
[409] | 154 | USE earth_const |
---|
[381] | 155 | USE terminator |
---|
| 156 | IMPLICIT NONE |
---|
| 157 | INTEGER :: ngrid |
---|
| 158 | REAL(rstd) :: lat(ngrid) |
---|
| 159 | REAL(rstd) :: lon(ngrid) |
---|
| 160 | REAL(rstd) :: ps(ngrid) |
---|
| 161 | REAL(rstd) :: precl(ngrid) |
---|
| 162 | ! arguments with bottom-up indexing (DYNAMICO) |
---|
| 163 | REAL(rstd) :: p(ngrid,llm+1) |
---|
| 164 | REAL(rstd) :: pk(ngrid,llm) |
---|
| 165 | REAL(rstd) :: Temp(ngrid,llm) |
---|
| 166 | REAL(rstd) :: u(ngrid,llm) |
---|
| 167 | REAL(rstd) :: v(ngrid,llm) |
---|
| 168 | REAL(rstd) :: q(ngrid,llm,5) |
---|
| 169 | REAL(rstd) :: dTemp(ngrid,llm) |
---|
| 170 | REAL(rstd) :: du(ngrid,llm) |
---|
| 171 | REAL(rstd) :: dv(ngrid,llm) |
---|
| 172 | REAL(rstd) :: dq(ngrid,llm,5) |
---|
| 173 | ! local arrays with top-down vertical indexing (DCMIP) |
---|
| 174 | REAL(rstd) :: pint(ngrid,llm+1) |
---|
| 175 | REAL(rstd) :: pmid(ngrid,llm) |
---|
| 176 | REAL(rstd) :: pdel(ngrid,llm) |
---|
| 177 | REAL(rstd) :: Tfi(ngrid,llm) |
---|
| 178 | REAL(rstd) :: ufi(ngrid,llm) |
---|
| 179 | REAL(rstd) :: vfi(ngrid,llm) |
---|
| 180 | REAL(rstd) :: qfi(ngrid,llm,5) |
---|
| 181 | |
---|
[397] | 182 | REAL(rstd) :: rho(llm), z(llm), theta(llm), qv(llm),qc(llm),qr(llm) |
---|
[381] | 183 | REAL(rstd) :: lastz |
---|
| 184 | REAL(rstd) :: dcl1,dcl2 |
---|
[397] | 185 | INTEGER :: l,ll,ij |
---|
[381] | 186 | REAL(rstd) :: dt_phys, inv_dt |
---|
[397] | 187 | INTEGER :: simple_physic_testcase |
---|
| 188 | |
---|
[381] | 189 | ! prepare input fields and mirror vertical index |
---|
| 190 | ps(:) = p(:,1) ! surface pressure |
---|
| 191 | |
---|
| 192 | DO l=1,llm+1 |
---|
| 193 | DO ij=1,ngrid |
---|
| 194 | pint(ij,l)=p(ij,llm+2-l) |
---|
| 195 | ENDDO |
---|
| 196 | ENDDO |
---|
| 197 | |
---|
| 198 | DO l=1,llm |
---|
| 199 | ll=llm+1-l |
---|
| 200 | DO ij=1,ngrid |
---|
| 201 | pmid(ij,l)=0.5*(pint(ij,l)+pint(ij,l+1)) ! Pressure inside layers |
---|
| 202 | pdel(ij,l)=pint(ij,l+1)-pint(ij,l) ! Pressure difference between two layers |
---|
| 203 | ufi(ij,l)=u(ij,ll) |
---|
| 204 | vfi(ij,l)=v(ij,ll) |
---|
| 205 | qfi(ij,l,:)=q(ij,ll,:) |
---|
[409] | 206 | IF (physics_thermo==thermo_fake_moist) THEN |
---|
| 207 | Tfi(ij,l)=Temp(ij,ll)/(1+0.608*qfi(ij,l,1)) |
---|
| 208 | ELSE |
---|
| 209 | Tfi(ij,l)=Temp(ij,ll) |
---|
| 210 | ENDIF |
---|
[381] | 211 | ENDDO |
---|
| 212 | ENDDO |
---|
| 213 | |
---|
[416] | 214 | precl=0. |
---|
| 215 | IF (testcase==moist_baroclinic_full .OR. testcase==cyclone ) THEN |
---|
| 216 | IF (testcase==moist_baroclinic_full) simple_physic_testcase=1 |
---|
[397] | 217 | IF (testcase==cyclone) simple_physic_testcase=0 |
---|
| 218 | CALL simple_physics(ngrid, llm, dt_phys, lat, tfi, qfi(:,:,1) , ufi, vfi, pmid, pint, pdel, 1./pdel, ps, precl, & |
---|
[416] | 219 | simple_physic_testcase, .FALSE., PBL) |
---|
[381] | 220 | ENDIF |
---|
| 221 | |
---|
| 222 | |
---|
[416] | 223 | IF (testcase==moist_baroclinic_full .OR. testcase==moist_baroclinic_kessler .OR. testcase==cyclone .OR. testcase==supercell ) THEN |
---|
[381] | 224 | DO ij=1,ngrid |
---|
[385] | 225 | lastz=0 |
---|
[381] | 226 | DO l=1,llm |
---|
| 227 | ll=llm+1-l |
---|
[435] | 228 | rho(l) = pmid(ij,ll)/(287*Tfi(ij,ll)*(1+0.608*qfi(ij,ll,1))) |
---|
[409] | 229 | z(l)=lastz |
---|
| 230 | lastz=lastz+ (p(ij,l)-p(ij,l+1)) /g / rho(l) |
---|
[386] | 231 | theta(l)= Tfi(ij,ll) / ( pk(ij,l) / cpp) |
---|
[381] | 232 | ENDDO |
---|
| 233 | |
---|
[412] | 234 | DO l=1,llm-1 |
---|
| 235 | z(l)= 0.5*(z(l)+z(l+1)) |
---|
| 236 | ENDDO |
---|
| 237 | z(llm)=z(llm)+(z(llm)-z(llm-1)) |
---|
| 238 | |
---|
| 239 | qv(:)=max(qfi(ij,llm:1:-1,1),0.) |
---|
| 240 | qc(:)=max(qfi(ij,llm:1:-1,2),0.) |
---|
| 241 | qr(:)=max(qfi(ij,llm:1:-1,3),0.) |
---|
| 242 | |
---|
[409] | 243 | CALL KESSLER(theta(:), qv, qc, qr, rho(:), & |
---|
| 244 | pk(ij,:)/cpp, dt_phys, z(:), llm, precl(ij)) |
---|
[397] | 245 | |
---|
| 246 | |
---|
[381] | 247 | DO l=1,llm |
---|
| 248 | ll=llm+1-l |
---|
[386] | 249 | Tfi(ij,ll) = theta(l) * ( pk(ij,l) / cpp) |
---|
[381] | 250 | ENDDO |
---|
[397] | 251 | |
---|
| 252 | qfi(ij,:,1)=qv(llm:1:-1) |
---|
| 253 | qfi(ij,:,2)=qc(llm:1:-1) |
---|
| 254 | qfi(ij,:,3)=qr(llm:1:-1) |
---|
| 255 | |
---|
[381] | 256 | ENDDO |
---|
| 257 | ENDIF |
---|
| 258 | |
---|
| 259 | DO l=1,llm |
---|
| 260 | ll=llm+1-l |
---|
| 261 | DO ij=1,ngrid |
---|
| 262 | CALL tendency_terminator( lat(ij), lon(ij), qfi(ij,ll,4), qfi(ij,ll,5), dt_phys, dcl1, dcl2) |
---|
| 263 | qfi(ij,ll,4)=qfi(ij,ll,4)+ dt_phys*dcl1 |
---|
| 264 | qfi(ij,ll,5)=qfi(ij,ll,5)+ dt_phys*dcl2 |
---|
| 265 | ENDDO |
---|
| 266 | ENDDO |
---|
| 267 | |
---|
| 268 | |
---|
| 269 | ! Mirror vertical index and compute tendencies |
---|
| 270 | inv_dt = 1./dt_phys |
---|
| 271 | DO l=1,llm |
---|
| 272 | ll=llm+1-l |
---|
| 273 | DO ij=1,ngrid |
---|
[409] | 274 | IF (physics_thermo==thermo_fake_moist) THEN |
---|
| 275 | dTemp(ij,l) = inv_dt * ( Tfi(ij,ll)*(1+0.608*qfi(ij,ll,1)) - Temp(ij,l) ) |
---|
| 276 | ELSE |
---|
| 277 | dTemp(ij,l) = inv_dt * ( Tfi(ij,ll) - Temp(ij,l) ) |
---|
| 278 | ENDIF |
---|
| 279 | |
---|
[381] | 280 | du(ij,l) = inv_dt * (ufi(ij,ll) - u(ij,l)) |
---|
| 281 | dv(ij,l) = inv_dt * (vfi(ij,ll) - v(ij,l)) |
---|
| 282 | dq(ij,l,:) = inv_dt * (qfi(ij,ll,:) - q(ij,l,:)) |
---|
| 283 | ENDDO |
---|
| 284 | ENDDO |
---|
| 285 | |
---|
| 286 | END SUBROUTINE compute_physics |
---|
| 287 | |
---|
| 288 | END MODULE physics_dcmip2016_mod |
---|
| 289 | |
---|
| 290 | |
---|