New URL for NEMO forge!   http://forge.nemo-ocean.eu

Since March 2022 along with NEMO 4.2 release, the code development moved to a self-hosted GitLab.
This present forge is now archived and remained online for history.
lbc_lnk_multi_generic.h90 in NEMO/branches/2020/dev_r12512_HPC-04_mcastril_Mixed_Precision_implementation/src/OCE/LBC – NEMO

source: NEMO/branches/2020/dev_r12512_HPC-04_mcastril_Mixed_Precision_implementation/src/OCE/LBC/lbc_lnk_multi_generic.h90 @ 12603

Last change on this file since 12603 was 12603, checked in by orioltp, 4 years ago

Adding several interfaces to work with both single and double precision

  • Property svn:keywords set to Id
  • Property svn:mime-type set to text/x-fortran
File size: 6.2 KB
Line 
1#if defined SINGLE_PRECISION
2#   if defined DIM_2d
3#      define ARRAY_TYPE(i,j,k,l)   REAL(sp), DIMENSION(i,j)
4#      define PTR_TYPE              TYPE(PTR_2D_sp)
5#      define PTR_ptab              pt2d
6#   endif
7#   if defined DIM_3d
8#      define ARRAY_TYPE(i,j,k,l)   REAL(sp), DIMENSION(i,j,k)
9#      define PTR_TYPE              TYPE(PTR_3D_sp)
10#      define PTR_ptab              pt3d
11#   endif
12#   if defined DIM_4d
13#      define ARRAY_TYPE(i,j,k,l)   REAL(sp), DIMENSION(i,j,k,l)
14#      define PTR_TYPE              TYPE(PTR_4D_sp)
15#      define PTR_ptab              pt4d
16#   endif
17#   define PRECISION sp
18#else
19#   if defined DIM_2d
20#      define ARRAY_TYPE(i,j,k,l)   REAL(dp), DIMENSION(i,j)
21#      define PTR_TYPE              TYPE(PTR_2D_dp)
22#      define PTR_ptab              pt2d
23#   endif
24#   if defined DIM_3d
25#      define ARRAY_TYPE(i,j,k,l)   REAL(dp), DIMENSION(i,j,k)
26#      define PTR_TYPE              TYPE(PTR_3D_dp)
27#      define PTR_ptab              pt3d
28#   endif
29#   if defined DIM_4d
30#      define ARRAY_TYPE(i,j,k,l)   REAL(dp), DIMENSION(i,j,k,l)
31#      define PTR_TYPE              TYPE(PTR_4D_dp)
32#      define PTR_ptab              pt4d
33#   endif
34#   define PRECISION dp
35#endif
36
37   SUBROUTINE ROUTINE_MULTI( cdname                                                                             &
38      &                    , pt1, cdna1, psgn1, pt2 , cdna2 , psgn2 , pt3 , cdna3 , psgn3 , pt4, cdna4, psgn4   &
39      &                    , pt5, cdna5, psgn5, pt6 , cdna6 , psgn6 , pt7 , cdna7 , psgn7 , pt8, cdna8, psgn8   &
40      &                    , pt9, cdna9, psgn9, pt10, cdna10, psgn10, pt11, cdna11, psgn11                      &
41      &                    , kfillmode, pfillval, lsend, lrecv, ihlcom )
42      !!---------------------------------------------------------------------
43      CHARACTER(len=*)   ,                   INTENT(in   ) :: cdname  ! name of the calling subroutine
44      ARRAY_TYPE(:,:,:,:)          , TARGET, INTENT(inout) :: pt1     ! arrays on which the lbc is applied
45      ARRAY_TYPE(:,:,:,:), OPTIONAL, TARGET, INTENT(inout) :: pt2  , pt3  , pt4  , pt5  , pt6  , pt7  , pt8  , pt9  , pt10  , pt11
46      CHARACTER(len=1)                     , INTENT(in   ) :: cdna1   ! nature of pt2D. array grid-points
47      CHARACTER(len=1)   , OPTIONAL        , INTENT(in   ) :: cdna2, cdna3, cdna4, cdna5, cdna6, cdna7, cdna8, cdna9, cdna10, cdna11
48      REAL(wp)                             , INTENT(in   ) :: psgn1   ! sign used across the north fold
49      REAL(wp)           , OPTIONAL        , INTENT(in   ) :: psgn2, psgn3, psgn4, psgn5, psgn6, psgn7, psgn8, psgn9, psgn10, psgn11
50      INTEGER            , OPTIONAL        , INTENT(in   ) :: kfillmode   ! filling method for halo over land (default = constant)
51      REAL(wp)           , OPTIONAL        , INTENT(in   ) :: pfillval    ! background value (used at closed boundaries)
52      LOGICAL, DIMENSION(4), OPTIONAL      , INTENT(in   ) :: lsend, lrecv   ! indicate how communications are to be carried out
53      INTEGER            , OPTIONAL        , INTENT(in   ) :: ihlcom         ! number of ranks and rows to be communicated
54      !!
55      INTEGER                          ::   kfld        ! number of elements that will be attributed
56      PTR_TYPE         , DIMENSION(11) ::   ptab_ptr    ! pointer array
57      CHARACTER(len=1) , DIMENSION(11) ::   cdna_ptr    ! nature of ptab_ptr grid-points
58      REAL(wp)         , DIMENSION(11) ::   psgn_ptr    ! sign used across the north fold boundary
59      !!---------------------------------------------------------------------
60      !
61      kfld = 0          ! initial array of pointer size
62      !
63      !                 ! Load the first array
64      CALL ROUTINE_LOAD( pt1, cdna1, psgn1, ptab_ptr, cdna_ptr, psgn_ptr, kfld )
65      !
66      !                 ! Look if more arrays are added
67      IF( PRESENT(psgn2 ) )   CALL ROUTINE_LOAD( pt2 , cdna2 , psgn2 , ptab_ptr, cdna_ptr, psgn_ptr, kfld )
68      IF( PRESENT(psgn3 ) )   CALL ROUTINE_LOAD( pt3 , cdna3 , psgn3 , ptab_ptr, cdna_ptr, psgn_ptr, kfld )
69      IF( PRESENT(psgn4 ) )   CALL ROUTINE_LOAD( pt4 , cdna4 , psgn4 , ptab_ptr, cdna_ptr, psgn_ptr, kfld )
70      IF( PRESENT(psgn5 ) )   CALL ROUTINE_LOAD( pt5 , cdna5 , psgn5 , ptab_ptr, cdna_ptr, psgn_ptr, kfld )
71      IF( PRESENT(psgn6 ) )   CALL ROUTINE_LOAD( pt6 , cdna6 , psgn6 , ptab_ptr, cdna_ptr, psgn_ptr, kfld )
72      IF( PRESENT(psgn7 ) )   CALL ROUTINE_LOAD( pt7 , cdna7 , psgn7 , ptab_ptr, cdna_ptr, psgn_ptr, kfld )
73      IF( PRESENT(psgn8 ) )   CALL ROUTINE_LOAD( pt8 , cdna8 , psgn8 , ptab_ptr, cdna_ptr, psgn_ptr, kfld )
74      IF( PRESENT(psgn9 ) )   CALL ROUTINE_LOAD( pt9 , cdna9 , psgn9 , ptab_ptr, cdna_ptr, psgn_ptr, kfld )
75      IF( PRESENT(psgn10) )   CALL ROUTINE_LOAD( pt10, cdna10, psgn10, ptab_ptr, cdna_ptr, psgn_ptr, kfld )
76      IF( PRESENT(psgn11) )   CALL ROUTINE_LOAD( pt11, cdna11, psgn11, ptab_ptr, cdna_ptr, psgn_ptr, kfld )
77      !
78      CALL lbc_lnk_ptr    ( cdname,               ptab_ptr, cdna_ptr, psgn_ptr, kfld, kfillmode, pfillval, lsend, lrecv, ihlcom )
79      !
80   END SUBROUTINE ROUTINE_MULTI
81
82
83   SUBROUTINE ROUTINE_LOAD( ptab, cdna, psgn, ptab_ptr, cdna_ptr, psgn_ptr, kfld )
84      !!---------------------------------------------------------------------
85      ARRAY_TYPE(:,:,:,:)   , TARGET, INTENT(inout) ::   ptab       ! arrays on which the lbc is applied
86      CHARACTER(len=1)              , INTENT(in   ) ::   cdna       ! nature of pt2d array grid-points
87      REAL(wp)                      , INTENT(in   ) ::   psgn       ! sign used across the north fold boundary
88      PTR_TYPE        , DIMENSION(:), INTENT(inout) ::   ptab_ptr   ! array of pointers
89      CHARACTER(len=1), DIMENSION(:), INTENT(inout) ::   cdna_ptr   ! nature of pt2d_array array grid-points
90      REAL(wp)        , DIMENSION(:), INTENT(inout) ::   psgn_ptr   ! sign used across the north fold boundary
91      INTEGER                       , INTENT(inout) ::   kfld       ! number of elements that has been attributed
92      !!---------------------------------------------------------------------
93      !
94      kfld                    =  kfld + 1
95      ptab_ptr(kfld)%PTR_ptab => ptab
96      cdna_ptr(kfld)          =  cdna
97      psgn_ptr(kfld)          =  psgn
98      !
99   END SUBROUTINE ROUTINE_LOAD
100
101#undef PRECISION
102#undef ARRAY_TYPE
103#undef PTR_TYPE
104#undef PTR_ptab
Note: See TracBrowser for help on using the repository browser.