[361] | 1 | MODULE caldyn_hevi_mod |
---|
| 2 | USE icosa |
---|
| 3 | USE transfert_mod |
---|
[731] | 4 | USE caldyn_vars_mod |
---|
| 5 | USE caldyn_kernels_hevi_mod |
---|
[362] | 6 | USE caldyn_kernels_base_mod |
---|
[831] | 7 | USE compute_theta_mod, ONLY : compute_theta |
---|
[842] | 8 | USE compute_caldyn_kv_mod, ONLY : compute_caldyn_kv |
---|
[844] | 9 | USE compute_caldyn_Coriolis_mod, ONLY : compute_caldyn_Coriolis |
---|
[849] | 10 | USE compute_caldyn_slow_hydro_mod, ONLY : compute_caldyn_slow_hydro |
---|
[850] | 11 | USE compute_caldyn_slow_NH_mod, ONLY : compute_caldyn_slow_NH |
---|
[853] | 12 | USE compute_caldyn_solver_mod, ONLY : compute_caldyn_solver |
---|
[361] | 13 | IMPLICIT NONE |
---|
| 14 | PRIVATE |
---|
| 15 | PUBLIC caldyn_hevi |
---|
| 16 | |
---|
| 17 | CONTAINS |
---|
| 18 | |
---|
| 19 | SUBROUTINE caldyn_hevi(write_out,tau, f_phis, f_ps, f_mass, f_theta_rhodz, f_u, f_q, & |
---|
[366] | 20 | f_W, f_geopot, f_hflux, f_wflux, f_dps, f_dmass, f_dtheta_rhodz, & |
---|
| 21 | f_du_slow, f_du_fast, f_dPhi_slow, f_dPhi_fast, f_dW_slow, f_dW_fast) |
---|
[361] | 22 | USE icosa |
---|
| 23 | USE observable_mod |
---|
| 24 | USE disvert_mod, ONLY : caldyn_eta, eta_mass |
---|
| 25 | USE vorticity_mod |
---|
| 26 | USE kinetic_mod |
---|
| 27 | USE theta2theta_rhodz_mod |
---|
| 28 | USE wind_mod |
---|
| 29 | USE mpipara |
---|
| 30 | USE trace |
---|
| 31 | USE omp_para |
---|
| 32 | USE output_field_mod |
---|
| 33 | USE checksum_mod |
---|
[827] | 34 | USE compute_mod, ONLY : compute_pvort_only |
---|
[361] | 35 | IMPLICIT NONE |
---|
| 36 | LOGICAL,INTENT(IN) :: write_out |
---|
| 37 | REAL(rstd), INTENT(IN) :: tau |
---|
| 38 | TYPE(t_field),POINTER :: f_phis(:) |
---|
| 39 | TYPE(t_field),POINTER :: f_ps(:) |
---|
| 40 | TYPE(t_field),POINTER :: f_mass(:) |
---|
| 41 | TYPE(t_field),POINTER :: f_theta_rhodz(:) |
---|
| 42 | TYPE(t_field),POINTER :: f_u(:) |
---|
| 43 | TYPE(t_field),POINTER :: f_q(:) |
---|
[366] | 44 | TYPE(t_field),POINTER :: f_W(:) |
---|
[361] | 45 | TYPE(t_field),POINTER :: f_geopot(:) |
---|
| 46 | TYPE(t_field),POINTER :: f_hflux(:), f_wflux(:) |
---|
| 47 | TYPE(t_field) :: f_dps(:) |
---|
| 48 | TYPE(t_field) :: f_dmass(:) |
---|
| 49 | TYPE(t_field) :: f_dtheta_rhodz(:) |
---|
| 50 | TYPE(t_field) :: f_du_slow(:) |
---|
| 51 | TYPE(t_field) :: f_du_fast(:) |
---|
[366] | 52 | TYPE(t_field) :: f_dW_slow(:) |
---|
| 53 | TYPE(t_field) :: f_dW_fast(:) |
---|
| 54 | TYPE(t_field) :: f_dPhi_slow(:) |
---|
| 55 | TYPE(t_field) :: f_dPhi_fast(:) |
---|
[361] | 56 | |
---|
[562] | 57 | REAL(rstd),POINTER :: ps(:), dps(:), phis(:) |
---|
[387] | 58 | REAL(rstd),POINTER :: mass(:,:), theta_rhodz(:,:,:), dtheta_rhodz(:,:,:) |
---|
[366] | 59 | REAL(rstd),POINTER :: du(:,:), dW(:,:), dPhi(:,:), hflux(:,:), wflux(:,:) |
---|
[735] | 60 | REAL(rstd),POINTER :: u(:,:), w(:,:), qu(:,:), qv(:,:), Kv(:,:), hv(:,:) |
---|
[361] | 61 | |
---|
| 62 | ! temporary shared variable |
---|
[404] | 63 | REAL(rstd),POINTER :: theta(:,:,:) |
---|
[361] | 64 | REAL(rstd),POINTER :: pk(:,:) |
---|
| 65 | REAL(rstd),POINTER :: geopot(:,:) |
---|
| 66 | REAL(rstd),POINTER :: convm(:,:) |
---|
| 67 | REAL(rstd),POINTER :: wwuu(:,:) |
---|
[558] | 68 | REAL(rstd),POINTER :: F_el(:,:), gradPhi2(:,:), w_il(:,:) , W_etadot(:,:), pres(:,:), m_il(:,:) |
---|
[361] | 69 | INTEGER :: ind |
---|
| 70 | LOGICAL,SAVE :: first=.TRUE. |
---|
| 71 | !$OMP THREADPRIVATE(first) |
---|
| 72 | |
---|
| 73 | IF (first) THEN |
---|
| 74 | first=.FALSE. |
---|
| 75 | IF(caldyn_eta==eta_mass) THEN |
---|
| 76 | CALL init_message(f_ps,req_i1,req_ps) |
---|
| 77 | ELSE |
---|
| 78 | CALL init_message(f_mass,req_i1,req_mass) |
---|
| 79 | END IF |
---|
| 80 | CALL init_message(f_theta_rhodz,req_i1,req_theta_rhodz) |
---|
| 81 | CALL init_message(f_u,req_e1_vect,req_u) |
---|
| 82 | CALL init_message(f_qu,req_e1_scal,req_qu) |
---|
[734] | 83 | IF(caldyn_kinetic==kinetic_consistent) CALL init_message(f_Kv,req_z1_scal,req_Kv) |
---|
[366] | 84 | IF(.NOT.hydrostatic) THEN |
---|
| 85 | CALL init_message(f_geopot,req_i1,req_geopot) |
---|
| 86 | CALL init_message(f_w,req_i1,req_w) |
---|
| 87 | END IF |
---|
[361] | 88 | ENDIF |
---|
| 89 | |
---|
| 90 | CALL trace_start("caldyn") |
---|
| 91 | |
---|
| 92 | IF(caldyn_eta==eta_mass) THEN |
---|
| 93 | CALL send_message(f_ps,req_ps) ! COM00 |
---|
[362] | 94 | CALL wait_message(req_ps) ! COM00 |
---|
[361] | 95 | ELSE |
---|
| 96 | CALL send_message(f_mass,req_mass) ! COM00 |
---|
| 97 | CALL wait_message(req_mass) ! COM00 |
---|
| 98 | END IF |
---|
| 99 | CALL send_message(f_theta_rhodz,req_theta_rhodz) ! COM01 |
---|
| 100 | CALL wait_message(req_theta_rhodz) ! COM01 Moved from caldyn_pvort |
---|
[366] | 101 | |
---|
| 102 | IF(.NOT.hydrostatic) THEN |
---|
| 103 | CALL send_message(f_geopot,req_geopot) ! COM03 |
---|
| 104 | CALL wait_message(req_geopot) ! COM03 |
---|
| 105 | CALL send_message(f_w,req_w) ! COM04 |
---|
| 106 | CALL wait_message(req_w) ! COM04 |
---|
| 107 | END IF |
---|
[361] | 108 | |
---|
| 109 | DO ind=1,ndomain |
---|
| 110 | IF (.NOT. assigned_domain(ind)) CYCLE |
---|
| 111 | CALL swap_dimensions(ind) |
---|
| 112 | CALL swap_geometry(ind) |
---|
| 113 | ps=f_ps(ind) |
---|
| 114 | theta_rhodz=f_theta_rhodz(ind) |
---|
| 115 | mass=f_mass(ind) |
---|
| 116 | theta = f_theta(ind) |
---|
[404] | 117 | CALL compute_theta(ps,theta_rhodz, mass,theta) |
---|
[361] | 118 | pk = f_pk(ind) |
---|
[362] | 119 | geopot = f_geopot(ind) |
---|
[369] | 120 | du=f_du_fast(ind) |
---|
[366] | 121 | IF(hydrostatic) THEN |
---|
[369] | 122 | du(:,:)=0. |
---|
[404] | 123 | CALL compute_geopot(mass,theta, ps,pk,geopot) |
---|
[366] | 124 | ELSE |
---|
[562] | 125 | phis = f_phis(ind) |
---|
[366] | 126 | W = f_W(ind) |
---|
| 127 | dW = f_dW_fast(ind) |
---|
| 128 | dPhi = f_dPhi_fast(ind) |
---|
[558] | 129 | ! reuse buffers |
---|
| 130 | m_il = f_wil(ind) |
---|
| 131 | pres = f_gradPhi2(ind) |
---|
[562] | 132 | CALL compute_caldyn_solver(tau,phis, mass,theta,pk,geopot,W, m_il,pres, dPhi,dW,du) ! computes d(Phi,W,du)_fast and updates Phi,W |
---|
[366] | 133 | END IF |
---|
| 134 | u=f_u(ind) |
---|
[373] | 135 | CALL compute_caldyn_fast(tau,u,mass,theta,pk,geopot,du) ! computes du_fast and updates u |
---|
[361] | 136 | ENDDO |
---|
| 137 | |
---|
| 138 | CALL send_message(f_u,req_u) ! COM02 |
---|
| 139 | CALL wait_message(req_u) ! COM02 |
---|
| 140 | |
---|
| 141 | DO ind=1,ndomain |
---|
| 142 | IF (.NOT. assigned_domain(ind)) CYCLE |
---|
| 143 | CALL swap_dimensions(ind) |
---|
| 144 | CALL swap_geometry(ind) |
---|
| 145 | u=f_u(ind) |
---|
| 146 | mass=f_mass(ind) |
---|
| 147 | qu=f_qu(ind) |
---|
| 148 | qv=f_qv(ind) |
---|
[735] | 149 | hv=f_hv(ind) |
---|
| 150 | CALL compute_pvort_only(u,mass,qu,qv,hv) |
---|
[734] | 151 | IF(caldyn_kinetic==kinetic_consistent) THEN |
---|
| 152 | Kv=f_Kv(ind) |
---|
| 153 | CALL compute_caldyn_Kv(u,Kv) |
---|
| 154 | END IF |
---|
[361] | 155 | ENDDO |
---|
| 156 | |
---|
| 157 | CALL send_message(f_qu,req_qu) ! COM03 |
---|
[369] | 158 | CALL wait_message(req_qu) ! COM03 |
---|
[734] | 159 | |
---|
| 160 | IF(caldyn_kinetic==kinetic_consistent) THEN |
---|
[735] | 161 | CALL transfert_request(f_hv,req_z1_scal) |
---|
[734] | 162 | CALL send_message(f_Kv,req_Kv) |
---|
| 163 | CALL wait_message(req_Kv) |
---|
| 164 | END IF |
---|
| 165 | |
---|
[361] | 166 | DO ind=1,ndomain |
---|
| 167 | IF (.NOT. assigned_domain(ind)) CYCLE |
---|
| 168 | CALL swap_dimensions(ind) |
---|
| 169 | CALL swap_geometry(ind) |
---|
| 170 | u=f_u(ind) |
---|
| 171 | mass=f_mass(ind) |
---|
| 172 | theta = f_theta(ind) |
---|
| 173 | qu=f_qu(ind) |
---|
| 174 | hflux=f_hflux(ind) |
---|
| 175 | convm = f_dmass(ind) |
---|
| 176 | dtheta_rhodz=f_dtheta_rhodz(ind) |
---|
| 177 | du=f_du_slow(ind) |
---|
[377] | 178 | |
---|
[369] | 179 | IF(hydrostatic) THEN |
---|
[735] | 180 | hv=f_hv(ind) |
---|
[734] | 181 | Kv=f_Kv(ind) |
---|
[735] | 182 | CALL compute_caldyn_slow_hydro(u,mass,hv, hflux,Kv,du, .TRUE.) |
---|
[369] | 183 | ELSE |
---|
| 184 | W = f_W(ind) |
---|
| 185 | dW = f_dW_slow(ind) |
---|
| 186 | geopot = f_geopot(ind) |
---|
| 187 | dPhi = f_dPhi_slow(ind) |
---|
[558] | 188 | F_el = f_Fel(ind) |
---|
| 189 | gradPhi2 = f_gradPhi2(ind) |
---|
| 190 | w_il = f_wil(ind) |
---|
| 191 | CALL compute_caldyn_slow_NH(u,mass,geopot,W, F_el,gradPhi2,w_il, hflux,du,dPhi,dW) |
---|
[369] | 192 | END IF |
---|
[404] | 193 | CALL compute_caldyn_Coriolis(hflux,theta,qu, convm,dtheta_rhodz,du) |
---|
[361] | 194 | IF(caldyn_eta==eta_mass) THEN |
---|
| 195 | wflux=f_wflux(ind) |
---|
| 196 | wwuu=f_wwuu(ind) |
---|
| 197 | dps=f_dps(ind) |
---|
[373] | 198 | CALL compute_caldyn_vert(u,theta,mass,convm, wflux,wwuu, dps, dtheta_rhodz, du) |
---|
| 199 | IF(.NOT.hydrostatic) THEN |
---|
[559] | 200 | W_etadot=f_Wetadot(ind) |
---|
[558] | 201 | CALL compute_caldyn_vert_NH(mass,geopot,W,wflux, W_etadot, du,dPhi,dW) |
---|
[369] | 202 | END IF |
---|
[361] | 203 | END IF |
---|
| 204 | ENDDO |
---|
| 205 | |
---|
| 206 | !$OMP BARRIER |
---|
| 207 | ! CALL check_mass_conservation(f_ps,f_dps) |
---|
| 208 | CALL trace_end("caldyn_hevi") |
---|
| 209 | !!$OMP BARRIER |
---|
| 210 | |
---|
| 211 | END SUBROUTINE caldyn_hevi |
---|
| 212 | |
---|
| 213 | END MODULE caldyn_hevi_mod |
---|