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

source: NEMO/branches/2019/dev_r11943_MERGE_2019/src/OCE/SBC/sbcice_if.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: 7.2 KB
Line 
1MODULE sbcice_if
2   !!======================================================================
3   !!                       ***  MODULE  sbcice  ***
4   !! Surface module :  update surface ocean boundary condition over ice
5   !!                   covered area using ice-if model
6   !!======================================================================
7   !! History :  3.0  !  2006-06  (G. Madec)  Original code
8   !!----------------------------------------------------------------------
9
10   !!----------------------------------------------------------------------
11   !!   sbc_ice_if    : update sbc in ice-covered area
12   !!----------------------------------------------------------------------
13   USE oce            ! ocean dynamics and tracers
14   USE dom_oce        ! ocean space and time domain
15   USE phycst         ! physical constants
16   USE eosbn2         ! equation of state
17   USE sbc_oce        ! surface boundary condition: ocean fields
18#if defined key_si3
19   USE ice            , ONLY :   a_i
20#else
21   USE sbc_ice        , ONLY :   a_i 
22#endif
23   !
24   USE in_out_manager ! I/O manager
25   USE iom            ! I/O manager library
26   USE fldread        ! read input field
27   USE lib_mpp        ! MPP library
28   USE lib_fortran    ! Fortran utilities (allows no signed zero when 'key_nosignedzero' defined) 
29
30   IMPLICIT NONE
31   PRIVATE
32
33   PUBLIC   sbc_ice_if      ! routine called in sbcmod
34
35   TYPE(FLD), ALLOCATABLE, DIMENSION(:) ::   sf_ice   ! structure of input ice-cover (file informations, fields read)
36   
37   !! * Substitutions
38#  include "do_loop_substitute.h90"
39   !!----------------------------------------------------------------------
40   !! NEMO/OCE 4.0 , NEMO Consortium (2018)
41   !! $Id$
42   !! Software governed by the CeCILL license (see ./LICENSE)
43   !!----------------------------------------------------------------------
44CONTAINS
45
46   SUBROUTINE sbc_ice_if( kt, Kbb, Kmm )
47      !!---------------------------------------------------------------------
48      !!                     ***  ROUTINE sbc_ice_if  ***
49      !!
50      !! ** Purpose :   handle surface boundary condition over ice cover area
51      !!      when sea-ice model are not used
52      !!
53      !! ** Method  : - read sea-ice cover climatology
54      !!              - blah blah blah, ...
55      !!
56      !! ** Action  :   utau, vtau : remain unchanged
57      !!                taum, wndm : remain unchanged
58      !!                qns, qsr   : update heat flux below sea-ice
59      !!                emp, sfx   : update freshwater flux below sea-ice
60      !!                fr_i       : update the ice fraction
61      !!---------------------------------------------------------------------
62      INTEGER, INTENT(in) ::   kt   ! ocean time step
63      INTEGER, INTENT(in) ::   Kbb, Kmm   ! ocean time level indices
64      !
65      INTEGER  ::   ji, jj     ! dummy loop indices
66      INTEGER  ::   ierror     ! return error code
67      INTEGER  ::   ios        ! Local integer output status for namelist read
68      REAL(wp) ::   ztrp, zsice, zt_fzp, zfr_obs
69      REAL(wp) ::   zqri, zqrj, zqrp, zqi
70      !!
71      CHARACTER(len=100) ::   cn_dir              ! Root directory for location of ice-if files
72      TYPE(FLD_N)        ::   sn_ice              ! informations about the fields to be read
73      NAMELIST/namsbc_iif/ cn_dir, sn_ice
74      !!---------------------------------------------------------------------
75      !                                         ! ====================== !
76      IF( kt == nit000 ) THEN                   !  First call kt=nit000  !
77         !                                      ! ====================== !
78         ! set file information
79         READ  ( numnam_ref, namsbc_iif, IOSTAT = ios, ERR = 901)
80901      IF( ios /= 0 )   CALL ctl_nam ( ios , 'namsbc_iif in reference namelist' )
81
82         READ  ( numnam_cfg, namsbc_iif, IOSTAT = ios, ERR = 902 )
83902      IF( ios >  0 )   CALL ctl_nam ( ios , 'namsbc_iif in configuration namelist' )
84         IF(lwm) WRITE ( numond, namsbc_iif )
85
86         ALLOCATE( sf_ice(1), STAT=ierror )
87         IF( ierror > 0 )   CALL ctl_stop( 'STOP', 'sbc_ice_if: unable to allocate sf_ice structure' )
88         ALLOCATE( sf_ice(1)%fnow(jpi,jpj,1) )
89         IF( sn_ice%ln_tint )   ALLOCATE( sf_ice(1)%fdta(jpi,jpj,1,2) )
90
91         ! fill sf_ice with sn_ice and control print
92         CALL fld_fill( sf_ice, (/ sn_ice /), cn_dir, 'sbc_ice_if', 'ice-if sea-ice model', 'namsbc_iif' )
93         !
94      ENDIF
95
96      CALL fld_read( kt, nn_fsbc, sf_ice )           ! Read input fields and provides the
97      !                                              ! input fields at the current time-step
98     
99      IF( MOD( kt-1, nn_fsbc) == 0 ) THEN
100         !
101         ztrp = -40.             ! restoring terme for temperature (w/m2/k)
102         zsice = - 0.04 / 0.8    ! ratio of isohaline compressibility over isotherme compressibility
103                                 ! ( d rho / dt ) / ( d rho / ds )      ( s = 34, t = -1.8 )
104         
105         CALL eos_fzp( sss_m(:,:), fr_i(:,:) )       ! sea surface freezing temperature [Celsius]
106         fr_i(:,:) = fr_i(:,:) * tmask(:,:,1)
107
108         IF( ln_cpl )   a_i(:,:,1) = fr_i(:,:)         
109
110         ! Flux and ice fraction computation
111         DO_2D_11_11
112            !
113            zt_fzp  = fr_i(ji,jj)                        ! freezing point temperature
114            zfr_obs = sf_ice(1)%fnow(ji,jj,1)            ! observed ice cover
115            !                                            ! ocean ice fraction (0/1) from the freezing point temperature
116            IF( sst_m(ji,jj) <= zt_fzp ) THEN   ;   fr_i(ji,jj) = 1.e0
117            ELSE                                ;   fr_i(ji,jj) = 0.e0
118            ENDIF
119
120            ts(ji,jj,1,jp_tem,Kmm) = MAX( ts(ji,jj,1,jp_tem,Kmm), zt_fzp )     ! avoid over-freezing point temperature
121
122            qsr(ji,jj) = ( 1. - zfr_obs ) * qsr(ji,jj)   ! solar heat flux : zero below observed ice cover
123
124            !                                            ! non solar heat flux : add a damping term
125            !      # ztrp*(t-(tgel-1.))  if observed ice and no opa ice   (zfr_obs=1 fr_i=0)
126            !      # ztrp*min(0,t-tgel)  if observed ice and opa ice      (zfr_obs=1 fr_i=1)
127            zqri = ztrp * ( ts(ji,jj,1,jp_tem,Kbb) - ( zt_fzp - 1.) )
128            zqrj = ztrp * MIN( 0., ts(ji,jj,1,jp_tem,Kbb) - zt_fzp )
129            zqrp = ( zfr_obs * ( (1. - fr_i(ji,jj) ) * zqri    &
130              &                 +      fr_i(ji,jj)   * zqrj ) ) * tmask(ji,jj,1)
131
132            !                                            ! non-solar heat flux
133            !      # qns unchanged              if no climatological ice              (zfr_obs=0)
134            !      # qns = zqrp                 if climatological ice and no opa ice  (zfr_obs=1, fr_i=0)
135            !      # qns = zqrp -2(-4) watt/m2  if climatological ice and opa ice     (zfr_obs=1, fr_i=1)
136            !                                   (-2=arctic, -4=antarctic)   
137            zqi = -3. + SIGN( 1._wp, ff_f(ji,jj) )
138            qns(ji,jj) = ( ( 1.- zfr_obs ) * qns(ji,jj)                             &
139               &          +      zfr_obs   * fr_i(ji,jj) * zqi ) * tmask(ji,jj,1)   &
140               &       + zqrp
141         END_2D
142         !
143      ENDIF
144      !
145   END SUBROUTINE sbc_ice_if
146
147   !!======================================================================
148END MODULE sbcice_if
Note: See TracBrowser for help on using the repository browser.