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

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

devel : towards Fortran driver for unstructured/LAM meshes

File size: 3.1 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  PROCEDURE(comp_pvort_only), POINTER :: &
10       ptr1 => compute_pvort_only_unst, &
11       ptr2 => compute_pvort_only_hex
12 
13  PUBLIC :: compute_pvort_only_hex, compute_pvort_only_unst
14
15CONTAINS
16 
17  SUBROUTINE compute_pvort_only_unst(u,rhodz,qu,qv, hv_)
18    USE ISO_C_BINDING, only : C_DOUBLE, C_FLOAT
19    USE data_unstructured_mod, ONLY : enter_trace, exit_trace, &
20         id_pvort_only, primal_num, dual_num, edge_num, &
21         dual_deg, dual_edge, dual_ne, dual_vertex, up, down, Av, fv, Riv2
22    FIELD_MASS :: rhodz
23    FIELD_U    :: u,qu
24    FIELD_Z    :: qv, hv_
25    DECLARE_INDICES
26    DECLARE_EDGES
27    DECLARE_VERTICES
28    NUM :: etav, hv
29    START_TRACE(id_pvort_only, 1,1,2) ! primal, dual, edge
30#include "../kernels_unst/pvort_only.k90"
31    STOP_TRACE
32  END SUBROUTINE compute_pvort_only_unst
33
34  SUBROUTINE compute_pvort_only_hex(u,rhodz,qu,qv,hv_)
35    USE icosa
36    USE trace, ONLY : trace_start, trace_end
37    USE caldyn_vars_mod, ONLY : dysl_pvort_only
38    USE omp_para, ONLY : ll_begin, ll_end
39    REAL(rstd),INTENT(IN)  :: u(iim*3*jjm,llm)
40    REAL(rstd),INTENT(INOUT) :: rhodz(iim*jjm,llm)
41    REAL(rstd),INTENT(OUT) :: qu(iim*3*jjm,llm)
42    REAL(rstd),INTENT(OUT) :: qv(iim*2*jjm,llm)
43    REAL(rstd),INTENT(OUT) :: hv_(iim*2*jjm,llm)
44
45    INTEGER :: ij,l
46    REAL(rstd) :: etav,hv,radius_m2
47
48    CALL trace_start("compute_pvort_only") 
49!!! Compute shallow-water potential vorticity
50    IF(dysl_pvort_only) THEN
51#include "../kernels_hex/pvort_only.k90"
52    ELSE
53
54    radius_m2=radius**(-2)
55    DO l = ll_begin,ll_end
56       !DIR$ SIMD
57       DO ij=ij_begin_ext,ij_end_ext
58          etav= 1./Av(ij+z_up)*(  ne_rup  * u(ij+u_rup,l)   &
59                  + ne_left * u(ij+t_rup+u_left,l)          &
60                  - ne_lup  * u(ij+u_lup,l) )                               
61          hv =   Riv2(ij,vup)          * rhodz(ij,l)        &
62               + Riv2(ij+t_rup,vldown) * rhodz(ij+t_rup,l)  &
63               + Riv2(ij+t_lup,vrdown) * rhodz(ij+t_lup,l)
64          qv(ij+z_up,l) = ( etav+fv(ij+z_up) )/hv
65          hv_(ij+z_up,l) = hv
66         
67          etav = 1./Av(ij+z_down)*(  ne_ldown * u(ij+u_ldown,l)   &
68               + ne_right * u(ij+t_ldown+u_right,l)               &
69               - ne_rdown * u(ij+u_rdown,l) )
70          hv =   Riv2(ij,vdown)        * rhodz(ij,l)              &
71               + Riv2(ij+t_ldown,vrup) * rhodz(ij+t_ldown,l)      &
72               + Riv2(ij+t_rdown,vlup) * rhodz(ij+t_rdown,l)
73          qv(ij+z_down,l) =( etav+fv(ij+z_down) )/hv
74          hv_(ij+z_down,l) = hv
75       ENDDO
76
77       !DIR$ SIMD
78       DO ij=ij_begin,ij_end
79          qu(ij+u_right,l) = 0.5*(qv(ij+z_rdown,l)+qv(ij+z_rup,l)) 
80          qu(ij+u_lup,l) = 0.5*(qv(ij+z_up,l)+qv(ij+z_lup,l)) 
81          qu(ij+u_ldown,l) = 0.5*(qv(ij+z_ldown,l)+qv(ij+z_down,l)) 
82       END DO
83
84    ENDDO
85   
86    END IF ! dysl
87    CALL trace_end("compute_pvort_only")
88
89  END SUBROUTINE compute_pvort_only_hex
90
91END MODULE compute_pvort_only_mod
Note: See TracBrowser for help on using the repository browser.