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.
iom_def.F90 in NEMO/branches/2019/dev_r11943_MERGE_2019/src/OCE/IOM – NEMO

source: NEMO/branches/2019/dev_r11943_MERGE_2019/src/OCE/IOM/iom_def.F90 @ 12340

Last change on this file since 12340 was 12340, checked in by acc, 4 years ago

Branch 2019/dev_r11943_MERGE_2019. This commit introduces basic do loop macro
substitution to the 2019 option 1, merge branch. These changes have been SETTE
tested. The only addition is the do_loop_substitute.h90 file in the OCE directory but
the macros defined therein are used throughout the code to replace identifiable, 2D-
and 3D- nested loop opening and closing statements with single-line alternatives. Code
indents are also adjusted accordingly.

The following explanation is taken from comments in the new header file:

This header file contains preprocessor definitions and macros used in the do-loop
substitutions introduced between version 4.0 and 4.2. The primary aim of these macros
is to assist in future applications of tiling to improve performance. This is expected
to be achieved by alternative versions of these macros in selected locations. The
initial introduction of these macros simply replaces all identifiable nested 2D- and
3D-loops with single line statements (and adjusts indenting accordingly). Do loops
are identifiable if they comform to either:

DO jk = ....

DO jj = .... DO jj = ...

DO ji = .... DO ji = ...
. OR .
. .

END DO END DO

END DO END DO

END DO

and white-space variants thereof.

Additionally, only loops with recognised jj and ji loops limits are treated; these are:
Lower limits of 1, 2 or fs_2
Upper limits of jpi, jpim1 or fs_jpim1 (for ji) or jpj, jpjm1 or fs_jpjm1 (for jj)

The macro naming convention takes the form: DO_2D_BT_LR where:

B is the Bottom offset from the PE's inner domain;
T is the Top offset from the PE's inner domain;
L is the Left offset from the PE's inner domain;
R is the Right offset from the PE's inner domain

So, given an inner domain of 2,jpim1 and 2,jpjm1, a typical example would replace:

DO jj = 2, jpj

DO ji = 1, jpim1
.
.

END DO

END DO

with:

DO_2D_01_10
.
.
END_2D

similar conventions apply to the 3D loops macros. jk loop limits are retained
through macro arguments and are not restricted. This includes the possibility of
strides for which an extra set of DO_3DS macros are defined.

In the example definition below the inner PE domain is defined by start indices of
(kIs, kJs) and end indices of (kIe, KJe)

#define DO_2D_00_00 DO jj = kJs, kJe ; DO ji = kIs, kIe
#define END_2D END DO ; END DO

TO DO:


Only conventional nested loops have been identified and replaced by this step. There are constructs such as:

DO jk = 2, jpkm1

z2d(:,:) = z2d(:,:) + e3w(:,:,jk,Kmm) * z3d(:,:,jk) * wmask(:,:,jk)

END DO

which may need to be considered.

  • Property svn:keywords set to Id
File size: 5.4 KB
Line 
1MODULE iom_def
2   !!======================================================================
3   !!                    ***  MODULE  iom_def ***
4   !! IOM variables definitions
5   !!======================================================================
6   !! History :  9.0  ! 2006 09  (S. Masson) Original code
7   !!             -   ! 2007 07  (D. Storkey) Add uldname
8   !!            4.0  ! 2017-11 (M. Andrejczuk) Extend IOM interface to write any 3D fields
9   !!----------------------------------------------------------------------
10   USE par_kind
11
12   IMPLICIT NONE
13   PRIVATE
14
15   INTEGER, PARAMETER, PUBLIC ::   jpdom_data          = 1   !: ( 1  :jpiglo, 1  :jpjglo)    !!gm to be suppressed
16   INTEGER, PARAMETER, PUBLIC ::   jpdom_global        = 2   !: ( 1  :jpiglo, 1  :jpjglo)
17   INTEGER, PARAMETER, PUBLIC ::   jpdom_local         = 3   !: One of the 3 following cases
18   INTEGER, PARAMETER, PUBLIC ::   jpdom_local_full    = 4   !: ( 1  :jpi   , 1  :jpi   )
19   INTEGER, PARAMETER, PUBLIC ::   jpdom_local_noextra = 5   !: ( 1  :nlci  , 1  :nlcj  )
20   INTEGER, PARAMETER, PUBLIC ::   jpdom_local_noovlap = 6   !: (nldi:nlei  ,nldj:nlej  )
21   INTEGER, PARAMETER, PUBLIC ::   jpdom_unknown       = 7   !: No dimension checking
22   INTEGER, PARAMETER, PUBLIC ::   jpdom_autoglo       = 8   !:
23   INTEGER, PARAMETER, PUBLIC ::   jpdom_autoglo_xy    = 9   !: Automatically set horizontal dimensions only
24   INTEGER, PARAMETER, PUBLIC ::   jpdom_autodta       = 10  !:
25
26   INTEGER, PARAMETER, PUBLIC ::   jp_r8    = 200      !: write REAL(8)
27   INTEGER, PARAMETER, PUBLIC ::   jp_r4    = 201      !: write REAL(4)
28   INTEGER, PARAMETER, PUBLIC ::   jp_i4    = 202      !: write INTEGER(4)
29   INTEGER, PARAMETER, PUBLIC ::   jp_i2    = 203      !: write INTEGER(2)
30   INTEGER, PARAMETER, PUBLIC ::   jp_i1    = 204      !: write INTEGER(1)
31
32   INTEGER, PARAMETER, PUBLIC ::   jpmax_files  = 100  !: maximum number of simultaneously opened file
33   INTEGER, PARAMETER, PUBLIC ::   jpmax_vars   = 1200 !: maximum number of variables in one file
34   INTEGER, PARAMETER, PUBLIC ::   jpmax_dims   =  4   !: maximum number of dimensions for one variable
35   INTEGER, PARAMETER, PUBLIC ::   jpmax_digits =  5   !: maximum number of digits for the cpu number in the file name
36
37
38!$AGRIF_DO_NOT_TREAT
39   INTEGER, PUBLIC            ::   iom_open_init = 0   !: used to initialize iom_file(:)%nfid to 0
40!XIOS write restart   
41   LOGICAL, PUBLIC            ::   lwxios          !: write single file restart using XIOS
42   INTEGER, PUBLIC            ::   nxioso          !: type of restart file when writing using XIOS 1 - single, 2 - multiple
43!XIOS read restart   
44   LOGICAL, PUBLIC            ::   lrxios          !: read single file restart using XIOS
45   LOGICAL, PUBLIC            ::   lxios_sini = .FALSE. ! is restart in a single file
46   LOGICAL, PUBLIC            ::   lxios_set  = .FALSE. 
47
48
49
50   TYPE, PUBLIC ::   file_descriptor
51      CHARACTER(LEN=240)                        ::   name     !: name of the file
52      INTEGER                                   ::   nfid     !: identifier of the file (0 if closed)
53                                                              !: jpioipsl option has been removed)
54      INTEGER                                   ::   nvars    !: number of identified varibles in the file
55      INTEGER                                   ::   iduld    !: id of the unlimited dimension
56      INTEGER                                   ::   lenuld   !: length of the unlimited dimension (number of records in file)
57      INTEGER                                   ::   irec     !: writing record position 
58      CHARACTER(LEN=32)                         ::   uldname  !: name of the unlimited dimension
59      CHARACTER(LEN=32), DIMENSION(jpmax_vars)  ::   cn_var   !: names of the variables
60      INTEGER, DIMENSION(jpmax_vars)            ::   nvid     !: id of the variables
61      INTEGER, DIMENSION(jpmax_vars)            ::   ndims    !: number of dimensions of the variables
62      LOGICAL, DIMENSION(jpmax_vars)            ::   luld     !: variable using the unlimited dimension
63      INTEGER, DIMENSION(jpmax_dims,jpmax_vars) ::   dimsz    !: size of variables dimensions
64      REAL(kind=wp), DIMENSION(jpmax_vars)      ::   scf      !: scale_factor of the variables
65      REAL(kind=wp), DIMENSION(jpmax_vars)      ::   ofs      !: add_offset of the variables
66      INTEGER                                   ::   nlev     ! number of vertical levels
67   END TYPE file_descriptor
68   TYPE(file_descriptor), DIMENSION(jpmax_files), PUBLIC ::   iom_file !: array containing the info for all opened files
69   INTEGER, PARAMETER, PUBLIC                   :: max_rst_fields = 95 !: maximum number of restart variables defined in iom_set_rst_vars
70   TYPE, PUBLIC :: RST_FIELD 
71    CHARACTER(len=30) :: vname = "NO_NAME" ! names of variables in restart file
72    CHARACTER(len=30) :: grid = "NO_GRID"
73    LOGICAL           :: active =.FALSE. ! for restart write only: true - write field, false do not write field
74   END TYPE RST_FIELD
75!$AGRIF_END_DO_NOT_TREAT
76   !
77   TYPE(RST_FIELD), PUBLIC, SAVE :: rst_wfields(max_rst_fields), rst_rfields(max_rst_fields)
78   !
79   !! * Substitutions
80#  include "do_loop_substitute.h90"
81   !!----------------------------------------------------------------------
82   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
83   !! $Id$
84   !! Software governed by the CeCILL license (see ./LICENSE)
85   !!======================================================================
86END MODULE iom_def
Note: See TracBrowser for help on using the repository browser.