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

Last change on this file since 827 was 827, checked in by dubos, 5 years ago

devel : towards Fortran driver for unstructured/LAM meshes

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