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

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

devel: separate module for compute_caldyn_kv

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