source: codes/icosagcm/devel/src/dynamics/caldyn_hevi.f90 @ 849

Last change on this file since 849 was 849, checked in by jisesh, 5 years ago

devel: separate module for compute_caldyn_slow_hydro

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