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