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

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

devel: separate module for compute_NH_geopot

File size: 7.0 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  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
19CONTAINS
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_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       CALL compute_pvort_only(u,mass,qu,qv,hv)
153       IF(caldyn_kinetic==kinetic_consistent) THEN
154          Kv=f_Kv(ind)
155          CALL compute_caldyn_Kv(u,Kv)
156       END IF
157    ENDDO
158   
159    CALL send_message(f_qu,req_qu) ! COM03
160    CALL wait_message(req_qu) ! COM03
161
162    IF(caldyn_kinetic==kinetic_consistent) THEN
163       CALL transfert_request(f_hv,req_z1_scal)
164       CALL send_message(f_Kv,req_Kv)
165       CALL wait_message(req_Kv)
166    END IF
167
168    DO ind=1,ndomain
169       IF (.NOT. assigned_domain(ind)) CYCLE
170       CALL swap_dimensions(ind)
171       CALL swap_geometry(ind)
172       u=f_u(ind)
173       mass=f_mass(ind)
174       theta = f_theta(ind)
175       qu=f_qu(ind)
176       hflux=f_hflux(ind)
177       convm = f_dmass(ind)
178       dtheta_rhodz=f_dtheta_rhodz(ind)
179       du=f_du_slow(ind)
180
181       IF(hydrostatic) THEN
182          hv=f_hv(ind)
183          Kv=f_Kv(ind)
184          CALL compute_caldyn_slow_hydro(u,mass,hv, hflux,Kv,du, .TRUE.)
185       ELSE
186          W = f_W(ind)
187          dW = f_dW_slow(ind)
188          geopot = f_geopot(ind)
189          dPhi = f_dPhi_slow(ind)
190          F_el = f_Fel(ind)
191          gradPhi2 = f_gradPhi2(ind)
192          w_il = f_wil(ind)
193          CALL compute_caldyn_slow_NH(u,mass,geopot,W, F_el,gradPhi2,w_il, hflux,du,dPhi,dW)
194       END IF
195       CALL compute_caldyn_Coriolis(hflux,theta,qu, convm,dtheta_rhodz,du)
196       IF(caldyn_eta==eta_mass) THEN
197          wflux=f_wflux(ind)
198          wwuu=f_wwuu(ind)
199          dps=f_dps(ind)
200          CALL compute_caldyn_vert(u,theta,mass,convm, wflux,wwuu, dps, dtheta_rhodz, du)
201          IF(.NOT.hydrostatic) THEN
202             W_etadot=f_Wetadot(ind)
203             CALL compute_caldyn_vert_NH(mass,geopot,W,wflux, W_etadot, du,dPhi,dW)
204          END IF
205       END IF
206    ENDDO
207   
208!$OMP BARRIER
209    !    CALL check_mass_conservation(f_ps,f_dps)
210    CALL trace_end("caldyn_hevi")
211!!$OMP BARRIER
212   
213  END SUBROUTINE caldyn_hevi
214
215END MODULE caldyn_hevi_mod
Note: See TracBrowser for help on using the repository browser.