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