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

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

devel: separate module for compute_caldyn_slow_NH

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