source: codes/icosagcm/devel/src/dynamics/compute_pvort_only.F90 @ 879

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

devel : moved DYSL for compute_pvort_only into compute_pvort_only.F90

File size: 3.6 KB
Line 
1MODULE compute_pvort_only_mod
2  USE compute_mod, ONLY : comp_pvort_only
3  USE grid_param, ONLY : llm
4  IMPLICIT NONE
5  PRIVATE
6
7#include "../unstructured/unstructured.h90"
8
9  PUBLIC :: compute_pvort_only_hex, compute_pvort_only_unst
10
11CONTAINS
12
13  SUBROUTINE check_interface
14    PROCEDURE(comp_pvort_only), POINTER :: ptr
15    ptr => compute_pvort_only_unst
16    ptr => compute_pvort_only_hex
17  END SUBROUTINE check_interface
18 
19#if BEGIN_DYSL
20
21KERNEL(pvort_only)
22  FORALL_CELLS_EXT()
23    ON_DUAL
24      etav = 0.d0
25      FORALL_EDGES
26         etav = etav + SIGN*u(EDGE)
27      END_BLOCK
28      hv=0.
29      FORALL_VERTICES
30        hv = hv + RIV2*rhodz(VERTEX)
31      END_BLOCK
32      qv(DUAL_CELL) = (etav + FV*AV )/(hv*AV)
33    END_BLOCK
34  END_BLOCK
35
36  FORALL_CELLS()
37    ON_EDGES
38      qu(EDGE)=0.5d0*(qv(VERTEX1)+qv(VERTEX2))
39    END_BLOCK
40  END_BLOCK
41END_BLOCK
42
43#endif END_DYSL
44
45  SUBROUTINE compute_pvort_only_unst(u,rhodz,qu,qv, hv_)
46    USE ISO_C_BINDING, only : C_DOUBLE, C_FLOAT
47    USE data_unstructured_mod, ONLY : enter_trace, exit_trace, &
48         id_pvort_only, primal_num, dual_num, edge_num, &
49         dual_deg, dual_edge, dual_ne, dual_vertex, up, down, Av, fv, Riv2
50    FIELD_MASS :: rhodz
51    FIELD_U    :: u,qu
52    FIELD_Z    :: qv, hv_
53    DECLARE_INDICES
54    DECLARE_EDGES
55    DECLARE_VERTICES
56    NUM :: etav, hv
57    START_TRACE(id_pvort_only, 1,1,2) ! primal, dual, edge
58#include "../kernels_unst/pvort_only.k90"
59    STOP_TRACE
60  END SUBROUTINE compute_pvort_only_unst
61
62  SUBROUTINE compute_pvort_only_hex(u,rhodz,qu,qv,hv_)
63    USE icosa
64    USE trace, ONLY : trace_start, trace_end
65    USE caldyn_vars_mod, ONLY : dysl_pvort_only
66    USE omp_para, ONLY : ll_begin, ll_end
67    REAL(rstd),INTENT(IN)  :: u(iim*3*jjm,llm)
68    REAL(rstd),INTENT(INOUT) :: rhodz(iim*jjm,llm)
69    REAL(rstd),INTENT(OUT) :: qu(iim*3*jjm,llm)
70    REAL(rstd),INTENT(OUT) :: qv(iim*2*jjm,llm)
71    REAL(rstd),INTENT(OUT) :: hv_(iim*2*jjm,llm)
72
73    INTEGER :: ij,l
74    REAL(rstd) :: etav,hv,radius_m2
75
76    CALL trace_start("compute_pvort_only") 
77!!! Compute shallow-water potential vorticity
78    IF(dysl_pvort_only) THEN
79#include "../kernels_hex/pvort_only.k90"
80    ELSE
81
82    radius_m2=radius**(-2)
83    DO l = ll_begin,ll_end
84       !DIR$ SIMD
85       DO ij=ij_begin_ext,ij_end_ext
86          etav= 1./Av(ij+z_up)*(  ne_rup  * u(ij+u_rup,l)   &
87                  + ne_left * u(ij+t_rup+u_left,l)          &
88                  - ne_lup  * u(ij+u_lup,l) )                               
89          hv =   Riv2(ij,vup)          * rhodz(ij,l)        &
90               + Riv2(ij+t_rup,vldown) * rhodz(ij+t_rup,l)  &
91               + Riv2(ij+t_lup,vrdown) * rhodz(ij+t_lup,l)
92          qv(ij+z_up,l) = ( etav+fv(ij+z_up) )/hv
93          hv_(ij+z_up,l) = hv
94         
95          etav = 1./Av(ij+z_down)*(  ne_ldown * u(ij+u_ldown,l)   &
96               + ne_right * u(ij+t_ldown+u_right,l)               &
97               - ne_rdown * u(ij+u_rdown,l) )
98          hv =   Riv2(ij,vdown)        * rhodz(ij,l)              &
99               + Riv2(ij+t_ldown,vrup) * rhodz(ij+t_ldown,l)      &
100               + Riv2(ij+t_rdown,vlup) * rhodz(ij+t_rdown,l)
101          qv(ij+z_down,l) =( etav+fv(ij+z_down) )/hv
102          hv_(ij+z_down,l) = hv
103       ENDDO
104
105       !DIR$ SIMD
106       DO ij=ij_begin,ij_end
107          qu(ij+u_right,l) = 0.5*(qv(ij+z_rdown,l)+qv(ij+z_rup,l)) 
108          qu(ij+u_lup,l) = 0.5*(qv(ij+z_up,l)+qv(ij+z_lup,l)) 
109          qu(ij+u_ldown,l) = 0.5*(qv(ij+z_ldown,l)+qv(ij+z_down,l)) 
110       END DO
111
112    ENDDO
113   
114    END IF ! dysl
115    CALL trace_end("compute_pvort_only")
116
117  END SUBROUTINE compute_pvort_only_hex
118
119END MODULE compute_pvort_only_mod
120
Note: See TracBrowser for help on using the repository browser.