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.
Changeset 2200 – NEMO

Changeset 2200


Ignore:
Timestamp:
2010-10-11T13:43:18+02:00 (14 years ago)
Author:
smasson
Message:

merge trunk rev 2198 into DEV_r2106_LOCEAN2010

Location:
branches/DEV_r2106_LOCEAN2010
Files:
15 edited
1 copied

Legend:

Unmodified
Added
Removed
  • branches/DEV_r2106_LOCEAN2010/CONFIG/POMME/EXP00/namelist

    r2114 r2200  
    178178   sn_prec     = 'precip_1988.nc' ,       -1          , 'precip'   ,    .true.      , .true. ,   'yearly' , '' 
    179179   sn_snow     = 'precip_1988.nc' ,       -1          , 'precip'   ,    .true.      , .true. ,   'yearly' , '' 
     180   sn_tdif     = 'taudif_core'    ,       24          , 'taudif'   ,    .true.      , .true.  ,   'yearly'  ,'' 
    180181! 
    181182   cn_dir      = './'      !  root directory for the location of the bulk files 
     
    316317    rn_dpsin   =    1.     !     -           -         -       south   -      - 
    317318    rn_dpeob   = 1500.     !  time relaxation (days) for the east  open boundary 
    318     rn_dpwob   =   15.     !     -           -         -     west    -      - 
     319    rn_dpwob   =  150.     !     -           -         -     west    -      - 
    319320    rn_dpnob   =  150.     !     -           -         -     north   -      - 
    320     rn_dpsob   =   15.     !     -           -         -     south   -      - 
     321    rn_dpsob   =  150.     !     -           -         -     south   -      - 
    321322    rn_volemp  =  1.       !  = 0 the total volume change with the surface flux (E-P-R) 
    322323                           !  = 1 the total volume remains constant 
  • branches/DEV_r2106_LOCEAN2010/NEMO/OPA_SRC/DOM/daymod.F90

    r1730 r2200  
    239239      ENDIF 
    240240 
    241       IF( lrst_oce )   CALL day_rst( kt, 'WRITE' ) 
     241      CALL rst_opn( kt )                                ! Open the restart file if needed and control lrst_oce 
     242      IF( lrst_oce )   CALL day_rst( kt, 'WRITE' )      ! write day restart information 
    242243      ! 
    243244   END SUBROUTINE day 
  • branches/DEV_r2106_LOCEAN2010/NEMO/OPA_SRC/DYN/dynspg_ts.F90

    r2000 r2200  
    595595            vn_b (:,:) = vn_b(:,:) * hvr(:,:) 
    596596         ENDIF 
     597         IF( iom_varid( numror, 'sshn_b', ldstop = .FALSE. ) > 0 ) THEN 
     598            CALL iom_get( numror, jpdom_autoglo, 'sshn_b' , sshn_b (:,:) )   ! filtered extrenal ssh 
     599         ELSE 
     600            sshn_b(:,:)=sshb(:,:)   ! if not in restart set previous time mean to current baroclinic before value    
     601         ENDIF  
    597602      ELSEIF( TRIM(cdrw) == 'WRITE' ) THEN 
    598          CALL iom_rstput( kt, nitrst, numrow, 'un_b'  , un_b  (:,:) )   ! external velocity issued 
    599          CALL iom_rstput( kt, nitrst, numrow, 'vn_b'  , vn_b  (:,:) )   ! from barotropic loop 
     603         CALL iom_rstput( kt, nitrst, numrow, 'un_b'   , un_b  (:,:) )   ! external velocity and ssh 
     604         CALL iom_rstput( kt, nitrst, numrow, 'vn_b'   , vn_b  (:,:) )   ! issued from barotropic loop 
     605         CALL iom_rstput( kt, nitrst, numrow, 'sshn_b' , sshn_b(:,:) )   !  
    600606      ENDIF 
    601607      ! 
  • branches/DEV_r2106_LOCEAN2010/NEMO/OPA_SRC/IOM/iom_ioipsl.F90

    r1488 r2200  
    8181         iln = INDEX( cdname, '.nc' ) 
    8282         IF( ldwrt ) THEN  ! the file should be open in write mode so we create it... 
    83             IF( llclobber ) THEN   ;   clstatus = 'REPLACE'  
    84             ELSE                   ;   clstatus = 'NEW' 
     83            IF( llclobber ) THEN   ;   clstatus = 'REPLACE 64'  
     84            ELSE                   ;   clstatus = 'NEW 64' 
    8585            ENDIF 
    8686            IF( jpnij > 1 ) THEN 
  • branches/DEV_r2106_LOCEAN2010/NEMO/OPA_SRC/IOM/iom_nf90.F90

    r1488 r2200  
    9494            IF(lwp) WRITE(numout,*) TRIM(clinfo)//' create new file: '//TRIM(cdname)//' in WRITE mode' 
    9595 
    96             IF( llclobber ) THEN   ;   imode = NF90_CLOBBER  
    97             ELSE                   ;   imode = NF90_NOCLOBBER  
     96            IF( llclobber ) THEN   ;   imode = IOR( NF90_64BIT_OFFSET, NF90_CLOBBER   ) 
     97            ELSE                   ;   imode = IOR( NF90_64BIT_OFFSET, NF90_NOCLOBBER )  
    9898            ENDIF 
    9999            CALL iom_nf90_check(NF90_CREATE( TRIM(cdname), imode, if90id, chunksize = ichunk ), clinfo) 
  • branches/DEV_r2106_LOCEAN2010/NEMO/OPA_SRC/LDF/ldfdyn_c1d.h90

    r1954 r2200  
    2828 
    2929      !! * Local variables 
     30      INTEGER  ::   jk   ! dummy loop indice 
    3031      REAL(wp) ::    zdam,  zwam,  zm00,  zm01,  zmhf,  zmhs 
    3132      REAL(wp) ::   zdam2, zwam2, zm200, zm201, zmh2f, zmh2s 
  • branches/DEV_r2106_LOCEAN2010/NEMO/OPA_SRC/OBC/obc_oce.F90

    r1953 r2200  
    8787   INTEGER ::   nje1m2, nje0m1    !: do loop index in mpp case for jpjefm1-1,jpjed 
    8888 
    89    REAL(wp), DIMENSION(jpjed:jpjef) ::   &  !: 
     89   REAL(wp), DIMENSION(jpj) ::   &  !: 
    9090      sshfoe,           & !: now climatology of the east boundary sea surface height 
    9191      ubtfoe,vbtfoe       !: now climatology of the east boundary barotropic transport 
     
    9797      !                   ! in the obcdyn.F90 routine 
    9898 
    99    REAL(wp), DIMENSION(jpjed:jpjef,jpj) ::   sshfoe_b      !: east boundary ssh correction averaged over the barotropic loop 
    100       !                                                    !  (if Flather's algoritm applied at open boundary) 
     99   REAL(wp), DIMENSION(jpi,jpj) ::   sshfoe_b      !: east boundary ssh correction averaged over the barotropic loop 
     100      !                                            !  (if Flather's algoritm applied at open boundary) 
    101101 
    102102   !!------------------------------- 
     
    124124   INTEGER ::   njw1m2, njw0m1     !: do loop index in mpp case for jpjwfm2,jpjwd 
    125125 
    126    REAL(wp), DIMENSION(jpjwd:jpjwf) ::   &  !: 
     126   REAL(wp), DIMENSION(jpj) ::   &  !: 
    127127      sshfow,           & !: now climatology of the west boundary sea surface height 
    128128      ubtfow,vbtfow       !: now climatology of the west boundary barotropic transport 
     
    134134      !                   !  in the obcdyn.F90 routine 
    135135 
    136    REAL(wp), DIMENSION(jpjwd:jpjwf,jpj) ::   sshfow_b    !: west boundary ssh correction averaged over the barotropic loop 
    137       !                                                  !  (if Flather's algoritm applied at open boundary) 
     136   REAL(wp), DIMENSION(jpi,jpj) ::   sshfow_b    !: west boundary ssh correction averaged over the barotropic loop 
     137      !                                          !  (if Flather's algoritm applied at open boundary) 
    138138 
    139139   !!------------------------------- 
     
    162162   INTEGER ::   njn0m1, njn1m1     !: do loop index in mpp case for jpnob-1 
    163163 
    164    REAL(wp), DIMENSION(jpind:jpinf) ::   &  !: 
     164   REAL(wp), DIMENSION(jpi) ::   &  !: 
    165165      sshfon,           & !: now climatology of the north boundary sea surface height 
    166166      ubtfon,vbtfon       !: now climatology of the north boundary barotropic transport 
     
    172172      !                   !  in yhe obcdyn.F90 routine 
    173173 
    174    REAL(wp), DIMENSION(jpind:jpinf,jpj) ::   sshfon_b      !: north boundary ssh correction averaged over the barotropic loop 
    175       !                                                    !  (if Flather's algoritm applied at open boundary) 
     174   REAL(wp), DIMENSION(jpi,jpj) ::   sshfon_b      !: north boundary ssh correction averaged over the barotropic loop 
     175      !                                            !  (if Flather's algoritm applied at open boundary) 
    176176 
    177177   !!-------------------------------- 
     
    199199   INTEGER ::   njs0p1, njs1p1     !: do loop index in mpp case for jpsob+1 
    200200 
    201    REAL(wp), DIMENSION(jpisd:jpisf) ::    &   !: 
     201   REAL(wp), DIMENSION(jpi) ::    &   !: 
    202202      sshfos,           & !: now climatology of the south boundary sea surface height 
    203203      ubtfos,vbtfos       !: now climatology of the south boundary barotropic transport 
     
    209209      !                   !  in the obcdyn.F90 routine 
    210210 
    211    REAL(wp), DIMENSION(jpisd:jpisf,jpj) ::   sshfos_b     !: south boundary ssh correction averaged over the barotropic loop 
    212       !                                                   !  (if Flather's algoritm applied at open boundary) 
     211   REAL(wp), DIMENSION(jpi,jpj) ::   sshfos_b     !: south boundary ssh correction averaged over the barotropic loop 
     212      !                                           !  (if Flather's algoritm applied at open boundary) 
    213213 
    214214   !!-------------------------------- 
  • branches/DEV_r2106_LOCEAN2010/NEMO/OPA_SRC/OBC/obcdta.F90

    r1970 r2200  
    11MODULE obcdta 
    2   !!============================================================================== 
    3   !!                            ***  MODULE obcdta  *** 
    4   !! Open boundary data : read the data for the open boundaries. 
    5   !!============================================================================== 
     2   !!============================================================================== 
     3   !!                            ***  MODULE obcdta  *** 
     4   !! Open boundary data : read the data for the open boundaries. 
     5   !!============================================================================== 
    66#if defined key_obc 
    7   !!------------------------------------------------------------------------------ 
    8   !!   'key_obc'         :                                Open Boundary Conditions 
    9   !!------------------------------------------------------------------------------ 
    10   !!   obc_dta           : read u, v, t, s data along each open boundary 
    11   !!------------------------------------------------------------------------------ 
    12   !! * Modules used 
    13   USE oce             ! ocean dynamics and tracers  
    14   USE dom_oce         ! ocean space and time domain 
    15   USE lbclnk          ! ocean lateral boundary conditions (or mpp link) 
    16   USE phycst          ! physical constants 
    17   USE obc_oce         ! ocean open boundary conditions 
    18   USE in_out_manager  ! I/O logical units 
    19   USE lib_mpp         ! distributed memory computing 
    20   USE dynspg_oce 
    21   USE ioipsl          ! now only for  ymds2ju function  
    22   USE iom             !  
    23  
    24   IMPLICIT NONE 
    25   PRIVATE 
    26  
    27   !! * Accessibility 
    28   PUBLIC obc_dta      ! routines called by step.F90 
    29   PUBLIC obc_dta_bt   ! routines called by dynspg_ts.F90 
    30  
    31   !! * Shared module variables 
    32   REAL(wp),  DIMENSION(2)              ::  zjcnes_obc   !  
    33   REAL(wp),  DIMENSION(:), ALLOCATABLE :: ztcobc 
    34   REAL(wp) :: rdt_obc 
    35   REAL(wp) :: zjcnes 
    36   INTEGER :: imm0, iyy0, idd0, iyy, imm, idd 
    37   INTEGER :: nt_a=2, nt_b=1, itobc, ndate0_cnes, nday_year0 
    38   INTEGER ::  itobce, itobcw, itobcs, itobcn, itobc_b  ! number of time steps in OBC files 
    39  
    40   INTEGER ::   & 
    41        ntobc      , &     !:  where we are in the obc file 
    42        ntobc_b    , &     !:  first record used 
    43        ntobc_a            !:  second record used 
    44  
    45   CHARACTER (len=40) :: &    ! name of data files 
    46        cl_obc_eTS   , cl_obc_eU,  & 
    47        cl_obc_wTS   , cl_obc_wU,  & 
    48        cl_obc_nTS   , cl_obc_nV,  & 
    49        cl_obc_sTS   , cl_obc_sV 
    50  
    51   ! arrays used for interpolating time dependent data on the boundaries 
    52   REAL(wp), DIMENSION(jpj,jpk,jptobc) :: uedta, vedta, tedta, sedta    ! East 
    53   REAL(wp), DIMENSION(jpj,jpk,jptobc) :: uwdta, vwdta, twdta, swdta    ! West 
    54   REAL(wp), DIMENSION(jpi,jpk,jptobc) :: undta, vndta, tndta, sndta    ! North 
    55   REAL(wp), DIMENSION(jpi,jpk,jptobc) :: usdta, vsdta, tsdta, ssdta    ! South 
    56  
    57   LOGICAL, DIMENSION (jpj,jpk ) :: ltemsk=.TRUE., luemsk=.TRUE., lvemsk=.TRUE.  ! boolean msks 
    58   LOGICAL, DIMENSION (jpj,jpk ) :: ltwmsk=.TRUE., luwmsk=.TRUE., lvwmsk=.TRUE.  ! used for outliers 
    59   LOGICAL, DIMENSION (jpi,jpk ) :: ltnmsk=.TRUE., lunmsk=.TRUE., lvnmsk=.TRUE.  ! checks 
    60   LOGICAL, DIMENSION (jpi,jpk ) :: ltsmsk=.TRUE., lusmsk=.TRUE., lvsmsk=.TRUE. 
    61  
    62   !! * Substitutions 
     7   !!------------------------------------------------------------------------------ 
     8   !!   'key_obc'         :                                Open Boundary Conditions 
     9   !!------------------------------------------------------------------------------ 
     10   !!   obc_dta           : read u, v, t, s data along each open boundary 
     11   !!------------------------------------------------------------------------------ 
     12   !! * Modules used 
     13   USE oce             ! ocean dynamics and tracers  
     14   USE dom_oce         ! ocean space and time domain 
     15   USE lbclnk          ! ocean lateral boundary conditions (or mpp link) 
     16   USE phycst          ! physical constants 
     17   USE obc_par         ! ocean open boundary conditions 
     18   USE obc_oce         ! ocean open boundary conditions 
     19   USE in_out_manager  ! I/O logical units 
     20   USE lib_mpp         ! distributed memory computing 
     21   USE dynspg_oce 
     22   USE ioipsl          ! now only for  ymds2ju function  
     23   USE iom             !  
     24 
     25   IMPLICIT NONE 
     26   PRIVATE 
     27 
     28   !! * Accessibility 
     29   PUBLIC obc_dta      ! routines called by step.F90 
     30   PUBLIC obc_dta_bt   ! routines called by dynspg_ts.F90 
     31 
     32   !! * Shared module variables 
     33   REAL(wp),  DIMENSION(2)              ::  zjcnes_obc   !  
     34   REAL(wp),  DIMENSION(:), ALLOCATABLE :: ztcobc 
     35   REAL(wp) :: rdt_obc 
     36   REAL(wp) :: zjcnes 
     37   INTEGER :: imm0, iyy0, idd0, iyy, imm, idd 
     38   INTEGER :: nt_a=2, nt_b=1, itobc, ndate0_cnes, nday_year0 
     39   INTEGER ::  itobce, itobcw, itobcs, itobcn, itobc_b  ! number of time steps in OBC files 
     40 
     41   INTEGER ::   & 
     42      ntobc      , &     !:  where we are in the obc file 
     43      ntobc_b    , &     !:  first record used 
     44      ntobc_a            !:  second record used 
     45 
     46   CHARACTER (len=40) :: &    ! name of data files 
     47      cl_obc_eTS   , cl_obc_eU,  & 
     48      cl_obc_wTS   , cl_obc_wU,  & 
     49      cl_obc_nTS   , cl_obc_nV,  & 
     50      cl_obc_sTS   , cl_obc_sV 
     51 
     52# if defined key_dynspg_ts 
     53   ! bt arrays for interpolating time dependent data on the boundaries 
     54   INTEGER :: nt_m=0, ntobc_m 
     55   REAL(wp), DIMENSION(jpj,0:jptobc) :: ubtedta, vbtedta, sshedta  ! East 
     56   REAL(wp), DIMENSION(jpj,0:jptobc) :: ubtwdta, vbtwdta, sshwdta ! West 
     57   REAL(wp), DIMENSION(jpi,0:jptobc) :: ubtndta, vbtndta, sshndta ! North 
     58   REAL(wp), DIMENSION(jpi,0:jptobc) :: ubtsdta, vbtsdta, sshsdta ! South 
     59   ! arrays used for interpolating time dependent data on the boundaries 
     60   REAL(wp), DIMENSION(jpj,jpk,0:jptobc) :: uedta, vedta, tedta, sedta    ! East 
     61   REAL(wp), DIMENSION(jpj,jpk,0:jptobc) :: uwdta, vwdta, twdta, swdta    ! West 
     62   REAL(wp), DIMENSION(jpi,jpk,0:jptobc) :: undta, vndta, tndta, sndta    ! North 
     63   REAL(wp), DIMENSION(jpi,jpk,0:jptobc) :: usdta, vsdta, tsdta, ssdta    ! South 
     64# else 
     65   ! bt arrays for interpolating time dependent data on the boundaries 
     66   REAL(wp), DIMENSION(jpj,jptobc) :: ubtedta, vbtedta, sshedta  ! East 
     67   REAL(wp), DIMENSION(jpj,jptobc) :: ubtwdta, vbtwdta, sshwdta        ! West 
     68   REAL(wp), DIMENSION(jpi,jptobc) :: ubtndta, vbtndta, sshndta        ! North 
     69   REAL(wp), DIMENSION(jpi,jptobc) :: ubtsdta, vbtsdta, sshsdta        ! South 
     70   ! arrays used for interpolating time dependent data on the boundaries 
     71   REAL(wp), DIMENSION(jpj,jpk,jptobc) :: uedta, vedta, tedta, sedta    ! East 
     72   REAL(wp), DIMENSION(jpj,jpk,jptobc) :: uwdta, vwdta, twdta, swdta    ! West 
     73   REAL(wp), DIMENSION(jpi,jpk,jptobc) :: undta, vndta, tndta, sndta    ! North 
     74   REAL(wp), DIMENSION(jpi,jpk,jptobc) :: usdta, vsdta, tsdta, ssdta    ! South 
     75# endif 
     76   LOGICAL, DIMENSION (jpj,jpk ) :: ltemsk=.TRUE., luemsk=.TRUE., lvemsk=.TRUE.  ! boolean msks 
     77   LOGICAL, DIMENSION (jpj,jpk ) :: ltwmsk=.TRUE., luwmsk=.TRUE., lvwmsk=.TRUE.  ! used for outliers 
     78   LOGICAL, DIMENSION (jpi,jpk ) :: ltnmsk=.TRUE., lunmsk=.TRUE., lvnmsk=.TRUE.  ! checks 
     79   LOGICAL, DIMENSION (jpi,jpk ) :: ltsmsk=.TRUE., lusmsk=.TRUE., lvsmsk=.TRUE. 
     80 
     81   !! * Substitutions 
    6382#  include "obc_vectopt_loop_substitute.h90" 
     83#  include "domzgr_substitute.h90" 
    6484   !!---------------------------------------------------------------------- 
    6585   !!   OPA 9.0 , LOCEAN-IPSL (2006) 
     
    7090CONTAINS 
    7191 
    72   SUBROUTINE obc_dta( kt ) 
    73     !!--------------------------------------------------------------------------- 
    74     !!                      ***  SUBROUTINE obc_dta  *** 
    75     !!                     
    76     !! ** Purpose :   Find the climatological  boundary arrays for the specified date,  
    77     !!                The boundary arrays are netcdf files. Three possible cases:  
    78     !!                - one time frame only in the file (time dimension = 1). 
    79     !!                in that case the boundary data does not change in time. 
    80     !!                - many time frames. In that case,  if we have 12 frames 
    81     !!                we assume monthly fields.  
    82     !!                Else, we assume that time_counter is in seconds  
    83     !!                since the beginning of either the current year or a reference 
    84     !!                year given in the namelist. 
    85     !!                (no check is done so far but one would have to check the "unit" 
    86     !!                 attribute of variable time_counter). 
    87     !! 
    88     !! 
    89     !! History : 
    90     !!        !  98-05 (J.M. Molines) Original code 
    91     !!   8.5  !  02-10 (C. Talandier, A-M. Treguier) Free surface, F90 
    92     !! 
    93     !!   9.0  !  04-06 (F. Durand, A-M. Treguier) Netcdf BC files on input 
    94     !!        !  2007-2008 (C. Langlais, P. Mathiot, J.M. Molines) high frequency boundaries data 
    95     !!--------------------------------------------------------------------------- 
    96     !! * Arguments 
    97     INTEGER, INTENT( in ) ::   kt          ! ocean time-step index 
    98  
    99     !! * Local declarations 
    100     INTEGER ::   ji, jj, jk, ii, ij ,it  ! dummy loop indices 
    101     INTEGER ::  ikprint                                ! frequency for printouts. 
    102     INTEGER, SAVE :: immfile, iyyfile                     ! 
    103     INTEGER :: nt              !  record indices (incrementation) 
    104     INTEGER :: istop           ! local error check 
    105  
    106     REAL(wp) ::   zxy, znum, zden ! time interpolation weight 
    107  
    108     ! variables for the julian day calculation 
    109     INTEGER :: iyear, imonth, iday 
    110     REAL(wp) :: zsec , zjulian, zjuliancnes    
    111  
    112     ! IOM STUFF 
    113     INTEGER ::  idvar, id_e, id_w, id_n, id_s, id_x       ! file identifiers 
    114     INTEGER, DIMENSION(1)  :: itmp 
    115     CHARACTER(LEN=25) :: cl_vname 
    116  
    117     !!--------------------------------------------------------------------------- 
    118  
    119     ! 0.  initialisation : 
    120     ! -------------------- 
    121     IF ( kt == nit000  )  CALL obc_dta_ini ( kt ) 
    122     IF ( nobc_dta == 0 )  RETURN   ! already done in obc_dta_ini 
    123     IF ( itobc == 1    )  RETURN   ! case of only one time frame in file done in obc_dta_ini 
    124  
    125     ! in the following code, we assume that obc data are read from files, with more than 1 time frame in it 
    126  
    127     iyyfile=iyy ; immfile = 00  ! set component of the current file name 
    128     IF ( cffile /= 'annual') immfile = imm   !  
    129     IF ( ln_obc_clim       ) iyyfile = 0000  ! assume that climatological files are labeled y0000 
    130  
    131     ! 1. Synchronize time of run with time of data files 
    132     !--------------------------------------------------- 
    133     ! nday_year is the day number in the current year ( 1 for 01/01 ) 
    134     zsec=MOD( (kt-nit000)*rdt - (nday_year - nday_year0 )*rday, rday ) ! number of seconds in the current day 
    135     IF (ln_obc_clim)  THEN  
    136       zjcnes = nday_year - 1  + zsec/rday 
    137     ELSE 
    138       zjcnes = zjcnes + rdt/rday 
    139     ENDIF 
    140  
    141     ! look for 'before' record number in the current file 
    142     ntobc = nrecbef ()  ! this function return the record number for 'before', relative to zjcnes 
    143  
    144     IF (MOD(kt-1,10)==0) THEN 
    145        IF (lwp) WRITE(numout,*) 'kt= ',kt,' zjcnes =', zjcnes,' ndastp =',ndastp, 'mm =',imm  
    146     END IF 
    147  
    148     ! 2. read a new data if necessary  
    149     !-------------------------------- 
    150     IF ( ntobc /= ntobc_b ) THEN 
    151     ! we need to read the 'after' record 
    152     ! swap working index: 
    153     nt=nt_b ; nt_b=nt_a ; nt_a=nt 
    154     ntobc_b = ntobc 
    155  
    156     ! new record number : 
    157     ntobc_a = ntobc_a + 1  
    158  
    159     ! all tricky things related to record number, changing files etc... are managed by obc_read 
    160       
    161     CALL obc_read (kt, nt_a, ntobc_a, iyyfile, immfile ) 
    162  
    163     ! update zjcnes_obc 
    164     zjcnes_obc(nt_b)= ztcobc(ntobc_b) 
    165     zjcnes_obc(nt_a)= ztcobc(ntobc_a) 
    166     ENDIF 
    167  
    168     ! 3.   interpolation at each time step 
    169     ! ------------------------------------ 
    170     IF ( ln_obc_clim) THEN 
    171       znum= MOD(zjcnes           - zjcnes_obc(nt_b), REAL(nyear_len(1),wp) ) ; IF ( znum < 0 ) znum = znum + REAL(nyear_len(1),wp) 
    172       zden= MOD(zjcnes_obc(nt_a) - zjcnes_obc(nt_b), REAL(nyear_len(1),wp) ) ; IF ( zden < 0 ) zden = zden + REAL(nyear_len(1),wp) 
    173     ELSE 
    174       znum= zjcnes           - zjcnes_obc(nt_b) 
    175       zden= zjcnes_obc(nt_a) - zjcnes_obc(nt_b) 
    176     ENDIF 
    177     zxy = znum / zden 
    178  
    179     IF( lp_obc_east ) THEN 
    180        !  fills sfoe, tfoe, ufoe ,vfoe 
    181        sfoe(:,:) = zxy * sedta (:,:,nt_a) + (1. - zxy)*sedta(:,:,nt_b) 
    182        tfoe(:,:) = zxy * tedta (:,:,nt_a) + (1. - zxy)*tedta(:,:,nt_b) 
    183        ufoe(:,:) = zxy * uedta (:,:,nt_a) + (1. - zxy)*uedta(:,:,nt_b) 
    184        vfoe(:,:) = zxy * vedta (:,:,nt_a) + (1. - zxy)*vedta(:,:,nt_b) 
    185     ENDIF 
    186  
    187     IF( lp_obc_west) THEN 
    188        !  fills sfow, tfow, ufow ,vfow 
    189        sfow(:,:) = zxy * swdta (:,:,nt_a) + (1. - zxy)*swdta(:,:,nt_b) 
    190        tfow(:,:) = zxy * twdta (:,:,nt_a) + (1. - zxy)*twdta(:,:,nt_b) 
    191        ufow(:,:) = zxy * uwdta (:,:,nt_a) + (1. - zxy)*uwdta(:,:,nt_b) 
    192        vfow(:,:) = zxy * vwdta (:,:,nt_a) + (1. - zxy)*vwdta(:,:,nt_b) 
    193     ENDIF 
    194  
    195     IF( lp_obc_north) THEN 
    196        !  fills sfon, tfon, ufon ,vfon 
    197        sfon(:,:) = zxy * sndta (:,:,nt_a) + (1. - zxy)*sndta(:,:,nt_b) 
    198        tfon(:,:) = zxy * tndta (:,:,nt_a) + (1. - zxy)*tndta(:,:,nt_b) 
    199        ufon(:,:) = zxy * undta (:,:,nt_a) + (1. - zxy)*undta(:,:,nt_b) 
    200        vfon(:,:) = zxy * vndta (:,:,nt_a) + (1. - zxy)*vndta(:,:,nt_b) 
    201     ENDIF 
    202  
    203     IF( lp_obc_south) THEN 
    204        !  fills sfos, tfos, ufos ,vfos 
    205        sfos(:,:) = zxy * ssdta (:,:,nt_a) + (1. - zxy)*ssdta(:,:,nt_b) 
    206        tfos(:,:) = zxy * tsdta (:,:,nt_a) + (1. - zxy)*tsdta(:,:,nt_b) 
    207        ufos(:,:) = zxy * usdta (:,:,nt_a) + (1. - zxy)*usdta(:,:,nt_b) 
    208        vfos(:,:) = zxy * vsdta (:,:,nt_a) + (1. - zxy)*vsdta(:,:,nt_b) 
    209     ENDIF 
    210   END SUBROUTINE obc_dta 
    211  
    212  
    213   SUBROUTINE obc_dta_ini (kt) 
    214     !!----------------------------------------------------------------------------- 
    215     !!                       ***  SUBROUTINE obc_dta_ini  *** 
    216     !! 
    217     !! ** Purpose : 
    218     !!      When obc_dta first call, realize some data initialization 
    219     !! 
    220     !! ** Method : 
    221     !! 
    222     !! History : 
    223     !!   9.0  ! 07-10 (J.M. Molines ) 
    224     !!---------------------------------------------------------------------------- 
    225     !! * Argument 
    226     INTEGER, INTENT(in)  :: kt      ! ocean time-step index 
    227  
    228     !! * Local declarations 
    229     INTEGER ::   ji,jj, it   ! dummy loop indices 
    230  
    231     REAL(wp) ::   zxy                                    ! time interpolation weight 
    232  
    233     INTEGER ::  ikprint                                ! frequency for printouts. 
    234  
    235     INTEGER, SAVE :: immfile, iyyfile                     ! 
    236     INTEGER :: nt              !  record indices (incrementation) 
    237     INTEGER :: istop           ! local error check 
    238  
    239     ! variables for the julian day calculation 
    240     INTEGER :: iyear, imonth, iday 
    241     REAL(wp) :: zsec , zjulian, zjuliancnes    
    242  
    243     ! IOM STUFF 
    244     INTEGER ::  idvar, id_e, id_w, id_n, id_s, id_x       ! file identifiers 
    245     INTEGER, DIMENSION(1)  :: itmp 
    246     CHARACTER(LEN=25) :: cl_vname 
    247  
    248     IF(lwp) WRITE(numout,*) 
    249     IF(lwp) WRITE(numout,*)  'obc_dta : find boundary data' 
    250     IF(lwp) WRITE(numout,*)  '~~~~~~~' 
    251     IF (lwp) THEN 
    252        IF ( nobc_dta == 0 ) THEN  
    253           WRITE(numout,*)  '          OBC data taken from initial conditions.' 
    254        ELSE       
    255           WRITE(numout,*)  '          OBC data taken from netcdf files.' 
    256        ENDIF 
    257     ENDIF 
    258     nday_year0 = nday_year  ! to remember the day when kt=nit000 
    259  
    260     sedta(:,:,:) = 0.e0 ; tedta(:,:,:) = 0.e0 ; uedta(:,:,:) = 0.e0 ; vedta(:,:,:) = 0.e0 ! East 
    261     swdta(:,:,:) = 0.e0 ; twdta(:,:,:) = 0.e0 ; uwdta(:,:,:) = 0.e0 ; vwdta(:,:,:) = 0.e0 ! West 
    262     sndta(:,:,:) = 0.e0 ; tndta(:,:,:) = 0.e0 ; undta(:,:,:) = 0.e0 ; vndta(:,:,:) = 0.e0 ! North 
    263     ssdta(:,:,:) = 0.e0 ; tsdta(:,:,:) = 0.e0 ; usdta(:,:,:) = 0.e0 ; vsdta(:,:,:) = 0.e0 ! South 
    264  
    265     sfoe(:,:) = 0.e0  ; tfoe(:,:) = 0.e0 ; ufoe(:,:) = 0.e0 ; vfoe(:,:) = 0.e0   ! East 
    266     sfow(:,:) = 0.e0  ; tfow(:,:) = 0.e0 ; ufow(:,:) = 0.e0 ; vfow(:,:) = 0.e0   ! West 
    267     sfon(:,:) = 0.e0  ; tfon(:,:) = 0.e0 ; ufon(:,:) = 0.e0 ; vfon(:,:) = 0.e0   ! North 
    268     sfos(:,:) = 0.e0  ; tfos(:,:) = 0.e0 ; ufos(:,:) = 0.e0 ; vfos(:,:) = 0.e0   ! South 
    269  
    270     IF (nobc_dta == 0 ) THEN   ! boundary data are the initial data of this run (set only at nit000) 
    271        IF (lp_obc_east) THEN  ! East 
    272           DO ji = nie0 , nie1     
    273              sfoe(nje0p1:nje1m1,:) = temsk(nje0p1:nje1m1,:) * sn (ji+1 , nje0p1:nje1m1 , :) 
    274              tfoe(nje0p1:nje1m1,:) = temsk(nje0p1:nje1m1,:) * tn (ji+1 , nje0p1:nje1m1 , :) 
    275              ufoe(nje0p1:nje1m1,:) = uemsk(nje0p1:nje1m1,:) * un (ji   , nje0p1:nje1m1 , :) 
    276              vfoe(nje0p1:nje1m1,:) = vemsk(nje0p1:nje1m1,:) * vn (ji+1 , nje0p1:nje1m1 , :) 
    277           END DO 
    278        ENDIF 
    279  
    280        IF (lp_obc_west) THEN  ! West 
    281           DO ji = niw0 , niw1     
    282              sfow(njw0p1:njw1m1,:) = twmsk(njw0p1:njw1m1,:) * sn (ji , njw0p1:njw1m1 , :) 
    283              tfow(njw0p1:njw1m1,:) = twmsk(njw0p1:njw1m1,:) * tn (ji , njw0p1:njw1m1 , :) 
    284              ufow(njw0p1:njw1m1,:) = uwmsk(njw0p1:njw1m1,:) * un (ji , njw0p1:njw1m1 , :) 
    285              vfow(njw0p1:njw1m1,:) = vwmsk(njw0p1:njw1m1,:) * vn (ji , njw0p1:njw1m1 , :) 
    286           END DO 
    287        ENDIF 
    288  
    289        IF (lp_obc_north) THEN ! North 
    290           DO jj = njn0 , njn1 
    291              sfon(nin0p1:nin1m1,:) = tnmsk(nin0p1:nin1m1,:) * sn (nin0p1:nin1m1 , jj+1 , :) 
    292              tfon(nin0p1:nin1m1,:) = tnmsk(nin0p1:nin1m1,:) * tn (nin0p1:nin1m1 , jj+1 , :) 
    293              ufon(nin0p1:nin1m1,:) = unmsk(nin0p1:nin1m1,:) * un (nin0p1:nin1m1 , jj+1 , :) 
    294              vfon(nin0p1:nin1m1,:) = vnmsk(nin0p1:nin1m1,:) * vn (nin0p1:nin1m1 , jj   , :) 
    295           END DO 
    296        ENDIF 
    297  
    298        IF (lp_obc_south) THEN ! South 
    299           DO jj = njs0 , njs1 
    300              sfos(nis0p1:nis1m1,:) = tsmsk(nis0p1:nis1m1,:) * sn (nis0p1:nis1m1 , jj , :) 
    301              tfos(nis0p1:nis1m1,:) = tsmsk(nis0p1:nis1m1,:) * tn (nis0p1:nis1m1 , jj , :) 
    302              ufos(nis0p1:nis1m1,:) = usmsk(nis0p1:nis1m1,:) * un (nis0p1:nis1m1 , jj , :) 
    303              vfos(nis0p1:nis1m1,:) = vsmsk(nis0p1:nis1m1,:) * vn (nis0p1:nis1m1 , jj , :) 
    304           END DO 
    305        ENDIF 
    306        RETURN  ! exit the routine all is done 
    307     ENDIF  ! nobc_dta = 0  
     92   SUBROUTINE obc_dta( kt ) 
     93      !!--------------------------------------------------------------------------- 
     94      !!                      ***  SUBROUTINE obc_dta  *** 
     95      !!                     
     96      !! ** Purpose :   Find the climatological  boundary arrays for the specified date,  
     97      !!                The boundary arrays are netcdf files. Three possible cases:  
     98      !!                - one time frame only in the file (time dimension = 1). 
     99      !!                in that case the boundary data does not change in time. 
     100      !!                - many time frames. In that case,  if we have 12 frames 
     101      !!                we assume monthly fields.  
     102      !!                Else, we assume that time_counter is in seconds  
     103      !!                since the beginning of either the current year or a reference 
     104      !!                year given in the namelist. 
     105      !!                (no check is done so far but one would have to check the "unit" 
     106      !!                 attribute of variable time_counter). 
     107      !! 
     108      !! 
     109      !! History : 
     110      !!        !  98-05 (J.M. Molines) Original code 
     111      !!   8.5  !  02-10 (C. Talandier, A-M. Treguier) Free surface, F90 
     112      !! 
     113      !!   9.0  !  04-06 (F. Durand, A-M. Treguier) Netcdf BC files on input 
     114      !!        !  2007-2008 (C. Langlais, P. Mathiot, J.M. Molines) high frequency boundaries data 
     115      !!--------------------------------------------------------------------------- 
     116      !! * Arguments 
     117      INTEGER, INTENT( in ) ::   kt          ! ocean time-step index 
     118 
     119      !! * Local declarations 
     120      INTEGER, SAVE :: immfile, iyyfile                     ! 
     121      INTEGER :: nt              !  record indices (incrementation) 
     122      REAL(wp) ::   zsec, zxy, znum, zden ! time interpolation weight 
     123 
     124      !!--------------------------------------------------------------------------- 
     125 
     126      ! 0.  initialisation : 
     127      ! -------------------- 
     128      IF ( kt == nit000  )  CALL obc_dta_ini ( kt ) 
     129      IF ( nobc_dta == 0 )  RETURN   ! already done in obc_dta_ini 
     130      IF ( itobc == 1    )  RETURN   ! case of only one time frame in file done in obc_dta_ini 
     131 
     132      ! in the following code, we assume that obc data are read from files, with more than 1 time frame in it 
     133 
     134      iyyfile=iyy ; immfile = 00  ! set component of the current file name 
     135      IF ( cffile /= 'annual') immfile = imm   !  
     136      IF ( ln_obc_clim       ) iyyfile = 0000  ! assume that climatological files are labeled y0000 
     137 
     138      ! 1. Synchronize time of run with time of data files 
     139      !--------------------------------------------------- 
     140      ! nday_year is the day number in the current year ( 1 for 01/01 ) 
     141      zsec=MOD( (kt-nit000)*rdt - (nday_year - nday_year0 )*rday, rday ) ! number of seconds in the current day 
     142      IF (ln_obc_clim)  THEN  
     143         zjcnes = nday_year - 1  + zsec/rday 
     144      ELSE 
     145         zjcnes = zjcnes + rdt/rday 
     146      ENDIF 
     147 
     148      ! look for 'before' record number in the current file 
     149      ntobc = nrecbef ()  ! this function return the record number for 'before', relative to zjcnes 
     150 
     151      IF (MOD(kt-1,10)==0) THEN 
     152         IF (lwp) WRITE(numout,*) 'kt= ',kt,' zjcnes =', zjcnes,' ndastp =',ndastp, 'mm =',imm  
     153      END IF 
     154 
     155      ! 2. read a new data if necessary  
     156      !-------------------------------- 
     157      IF ( ntobc /= ntobc_b ) THEN 
     158         ! we need to read the 'after' record 
     159         ! swap working index: 
     160# if defined key_dynspg_ts 
     161         nt=nt_m ; nt_m=nt_b ; nt_b=nt 
     162# endif 
     163         nt=nt_b ; nt_b=nt_a ; nt_a=nt 
     164         ntobc_b = ntobc 
     165 
     166         ! new record number : 
     167         ntobc_a = ntobc_a + 1  
     168 
     169         ! all tricky things related to record number, changing files etc... are managed by obc_read 
     170 
     171         CALL obc_read (kt, nt_a, ntobc_a, iyyfile, immfile ) 
     172 
     173         ! update zjcnes_obc 
     174# if defined key_dynspg_ts 
     175         ntobc_m=mod(ntobc_b-2+itobc,itobc)+1 
     176         zjcnes_obc(nt_m)= ztcobc(ntobc_m) 
     177# endif 
     178         zjcnes_obc(nt_b)= ztcobc(ntobc_b) 
     179         zjcnes_obc(nt_a)= ztcobc(ntobc_a) 
     180      ENDIF 
     181 
     182      ! 3.   interpolation at each time step 
     183      ! ------------------------------------ 
     184      IF( ln_obc_clim) THEN 
     185         znum= MOD(zjcnes           - zjcnes_obc(nt_b), REAL(nyear_len(1),wp) ) 
     186         IF( znum < 0 ) znum = znum + REAL(nyear_len(1),wp) 
     187         zden= MOD(zjcnes_obc(nt_a) - zjcnes_obc(nt_b), REAL(nyear_len(1),wp) )  
     188         IF( zden < 0 ) zden = zden + REAL(nyear_len(1),wp) 
     189      ELSE 
     190         znum= zjcnes           - zjcnes_obc(nt_b) 
     191         zden= zjcnes_obc(nt_a) - zjcnes_obc(nt_b) 
     192      ENDIF 
     193      zxy = znum / zden 
     194 
     195      IF( lp_obc_east ) THEN 
     196         !  fills sfoe, tfoe, ufoe ,vfoe 
     197         sfoe(:,:) = zxy * sedta (:,:,nt_a) + (1. - zxy)*sedta(:,:,nt_b) 
     198         tfoe(:,:) = zxy * tedta (:,:,nt_a) + (1. - zxy)*tedta(:,:,nt_b) 
     199         ufoe(:,:) = zxy * uedta (:,:,nt_a) + (1. - zxy)*uedta(:,:,nt_b) 
     200         vfoe(:,:) = zxy * vedta (:,:,nt_a) + (1. - zxy)*vedta(:,:,nt_b) 
     201      ENDIF 
     202 
     203      IF( lp_obc_west) THEN 
     204         !  fills sfow, tfow, ufow ,vfow 
     205         sfow(:,:) = zxy * swdta (:,:,nt_a) + (1. - zxy)*swdta(:,:,nt_b) 
     206         tfow(:,:) = zxy * twdta (:,:,nt_a) + (1. - zxy)*twdta(:,:,nt_b) 
     207         ufow(:,:) = zxy * uwdta (:,:,nt_a) + (1. - zxy)*uwdta(:,:,nt_b) 
     208         vfow(:,:) = zxy * vwdta (:,:,nt_a) + (1. - zxy)*vwdta(:,:,nt_b) 
     209      ENDIF 
     210 
     211      IF( lp_obc_north) THEN 
     212         !  fills sfon, tfon, ufon ,vfon 
     213         sfon(:,:) = zxy * sndta (:,:,nt_a) + (1. - zxy)*sndta(:,:,nt_b) 
     214         tfon(:,:) = zxy * tndta (:,:,nt_a) + (1. - zxy)*tndta(:,:,nt_b) 
     215         ufon(:,:) = zxy * undta (:,:,nt_a) + (1. - zxy)*undta(:,:,nt_b) 
     216         vfon(:,:) = zxy * vndta (:,:,nt_a) + (1. - zxy)*vndta(:,:,nt_b) 
     217      ENDIF 
     218 
     219      IF( lp_obc_south) THEN 
     220         !  fills sfos, tfos, ufos ,vfos 
     221         sfos(:,:) = zxy * ssdta (:,:,nt_a) + (1. - zxy)*ssdta(:,:,nt_b) 
     222         tfos(:,:) = zxy * tsdta (:,:,nt_a) + (1. - zxy)*tsdta(:,:,nt_b) 
     223         ufos(:,:) = zxy * usdta (:,:,nt_a) + (1. - zxy)*usdta(:,:,nt_b) 
     224         vfos(:,:) = zxy * vsdta (:,:,nt_a) + (1. - zxy)*vsdta(:,:,nt_b) 
     225      ENDIF 
     226   END SUBROUTINE obc_dta 
     227 
     228 
     229   SUBROUTINE obc_dta_ini (kt) 
     230      !!----------------------------------------------------------------------------- 
     231      !!                       ***  SUBROUTINE obc_dta_ini  *** 
     232      !! 
     233      !! ** Purpose : 
     234      !!      When obc_dta first call, realize some data initialization 
     235      !! 
     236      !! ** Method : 
     237      !! 
     238      !! History : 
     239      !!   9.0  ! 07-10 (J.M. Molines ) 
     240      !!---------------------------------------------------------------------------- 
     241      !! * Argument 
     242      INTEGER, INTENT(in)  :: kt      ! ocean time-step index 
     243 
     244      !! * Local declarations 
     245      INTEGER ::   ji, jj   ! dummy loop indices 
     246      INTEGER, SAVE :: immfile, iyyfile                     ! 
     247 
     248      ! variables for the julian day calculation 
     249      INTEGER :: iyear, imonth, iday 
     250      REAL(wp) :: zsec , zjulian, zjuliancnes    
     251 
     252      IF(lwp) WRITE(numout,*) 
     253      IF(lwp) WRITE(numout,*)  'obc_dta : find boundary data' 
     254      IF(lwp) WRITE(numout,*)  '~~~~~~~' 
     255      IF (lwp) THEN 
     256         IF ( nobc_dta == 0 ) THEN  
     257            WRITE(numout,*)  '          OBC data taken from initial conditions.' 
     258         ELSE       
     259            WRITE(numout,*)  '          OBC data taken from netcdf files.' 
     260         ENDIF 
     261      ENDIF 
     262      nday_year0 = nday_year  ! to remember the day when kt=nit000 
     263 
     264      sedta(:,:,:) = 0.e0 ; tedta(:,:,:) = 0.e0 ; uedta(:,:,:) = 0.e0 ; vedta(:,:,:) = 0.e0 ! East 
     265      swdta(:,:,:) = 0.e0 ; twdta(:,:,:) = 0.e0 ; uwdta(:,:,:) = 0.e0 ; vwdta(:,:,:) = 0.e0 ! West 
     266      sndta(:,:,:) = 0.e0 ; tndta(:,:,:) = 0.e0 ; undta(:,:,:) = 0.e0 ; vndta(:,:,:) = 0.e0 ! North 
     267      ssdta(:,:,:) = 0.e0 ; tsdta(:,:,:) = 0.e0 ; usdta(:,:,:) = 0.e0 ; vsdta(:,:,:) = 0.e0 ! South 
     268 
     269      sfoe(:,:) = 0.e0  ; tfoe(:,:) = 0.e0 ; ufoe(:,:) = 0.e0 ; vfoe(:,:) = 0.e0   ! East 
     270      sfow(:,:) = 0.e0  ; tfow(:,:) = 0.e0 ; ufow(:,:) = 0.e0 ; vfow(:,:) = 0.e0   ! West 
     271      sfon(:,:) = 0.e0  ; tfon(:,:) = 0.e0 ; ufon(:,:) = 0.e0 ; vfon(:,:) = 0.e0   ! North 
     272      sfos(:,:) = 0.e0  ; tfos(:,:) = 0.e0 ; ufos(:,:) = 0.e0 ; vfos(:,:) = 0.e0   ! South 
     273 
     274      IF (nobc_dta == 0 ) THEN   ! boundary data are the initial data of this run (set only at nit000) 
     275         IF (lp_obc_east) THEN  ! East 
     276            DO ji = nie0 , nie1     
     277               sfoe(nje0:nje1,:) = temsk(nje0:nje1,:) * sn (ji+1 , nje0:nje1 , :) * tmask(ji+1,nje0:nje1 , :) 
     278               tfoe(nje0:nje1,:) = temsk(nje0:nje1,:) * tn (ji+1 , nje0:nje1 , :) * tmask(ji+1,nje0:nje1 , :) 
     279               ufoe(nje0:nje1,:) = uemsk(nje0:nje1,:) * un (ji   , nje0:nje1 , :) * umask(ji,  nje0:nje1 , :) 
     280               vfoe(nje0:nje1,:) = vemsk(nje0:nje1,:) * vn (ji+1 , nje0:nje1 , :) * vmask(ji+1,nje0:nje1 , :) 
     281            END DO 
     282         ENDIF 
     283 
     284         IF (lp_obc_west) THEN  ! West 
     285            DO ji = niw0 , niw1     
     286               sfow(njw0:njw1,:) = twmsk(njw0:njw1,:) * sn (ji , njw0:njw1 , :) * tmask(ji , njw0:njw1 , :) 
     287               tfow(njw0:njw1,:) = twmsk(njw0:njw1,:) * tn (ji , njw0:njw1 , :) * tmask(ji , njw0:njw1 , :) 
     288               ufow(njw0:njw1,:) = uwmsk(njw0:njw1,:) * un (ji , njw0:njw1 , :) * umask(ji , njw0:njw1 , :) 
     289               vfow(njw0:njw1,:) = vwmsk(njw0:njw1,:) * vn (ji , njw0:njw1 , :) * vmask(ji , njw0:njw1 , :) 
     290            END DO 
     291         ENDIF 
     292 
     293         IF (lp_obc_north) THEN ! North 
     294            DO jj = njn0 , njn1 
     295               sfon(nin0:nin1,:) = tnmsk(nin0:nin1,:) * sn (nin0:nin1 , jj+1 , :) * tmask(nin0:nin1 , jj+1 , :) 
     296               tfon(nin0:nin1,:) = tnmsk(nin0:nin1,:) * tn (nin0:nin1 , jj+1 , :) * tmask(nin0:nin1 , jj+1 , :) 
     297               ufon(nin0:nin1,:) = unmsk(nin0:nin1,:) * un (nin0:nin1 , jj+1 , :) * umask(nin0:nin1 , jj+1 , :) 
     298               vfon(nin0:nin1,:) = vnmsk(nin0:nin1,:) * vn (nin0:nin1 , jj   , :) * vmask(nin0:nin1 , jj   , :) 
     299            END DO 
     300         ENDIF 
     301 
     302         IF (lp_obc_south) THEN ! South 
     303            DO jj = njs0 , njs1 
     304               sfos(nis0:nis1,:) = tsmsk(nis0:nis1,:) * sn (nis0:nis1 , jj , :) * tmask(nis0:nis1 , jj , :) 
     305               tfos(nis0:nis1,:) = tsmsk(nis0:nis1,:) * tn (nis0:nis1 , jj , :) * tmask(nis0:nis1 , jj , :) 
     306               ufos(nis0:nis1,:) = usmsk(nis0:nis1,:) * un (nis0:nis1 , jj , :) * umask(nis0:nis1 , jj , :) 
     307               vfos(nis0:nis1,:) = vsmsk(nis0:nis1,:) * vn (nis0:nis1 , jj , :) * vmask(nis0:nis1 , jj , :) 
     308            END DO 
     309         ENDIF 
     310         RETURN  ! exit the routine all is done 
     311      ENDIF  ! nobc_dta = 0  
    308312 
    309313!!!! In the following OBC data are read from files. 
    310     ! all logical-mask are initialzed to true when declared 
    311     WHERE ( temsk == 0 ) ltemsk=.FALSE.  
    312     WHERE ( uemsk == 0 ) luemsk=.FALSE.  
    313     WHERE ( vemsk == 0 ) lvemsk=.FALSE.  
    314  
    315     WHERE ( twmsk == 0 ) ltwmsk=.FALSE.  
    316     WHERE ( uwmsk == 0 ) luwmsk=.FALSE.  
    317     WHERE ( vwmsk == 0 ) lvwmsk=.FALSE.  
    318  
    319     WHERE ( tnmsk == 0 ) ltnmsk=.FALSE.  
    320     WHERE ( unmsk == 0 ) lunmsk=.FALSE.  
    321     WHERE ( vnmsk == 0 ) lvnmsk=.FALSE.  
    322  
    323     WHERE ( tsmsk == 0 ) ltsmsk=.FALSE.  
    324     WHERE ( usmsk == 0 ) lusmsk=.FALSE.  
    325     WHERE ( vsmsk == 0 ) lvsmsk=.FALSE.  
    326  
    327     iyear=1950;  imonth=01; iday=01;  zsec=0.  
    328     ! zjuliancnes : julian day corresonding  to  01/01/1950 
    329     CALL ymds2ju(iyear, imonth, iday,zsec , zjuliancnes) 
    330  
    331     !current year and curent month  
    332     iyy=INT(ndastp/10000) ; imm=INT((ndastp -iyy*10000)/100) ; idd=(ndastp-iyy*10000-imm*100) 
    333     IF (iyy <  1900)  iyy = iyy+1900  ! always assume that years are on 4 digits. 
    334     CALL ymds2ju(iyy, imm, idd ,zsec , zjulian) 
    335     ndate0_cnes = zjulian - zjuliancnes   ! jcnes day when call to obc_dta_ini 
    336  
    337     iyyfile=iyy ; immfile=0  ! set component of the current file name 
    338     IF ( cffile /= 'annual') immfile=imm 
    339     IF ( ln_obc_clim) iyyfile = 0  ! assume that climatological files are labeled y0000 
    340  
    341     CALL obc_dta_chktime ( iyyfile, immfile ) 
    342  
    343     IF ( itobc == 1 ) THEN  
    344        ! in this case we will provide boundary data only once. 
    345        nt_a=1 ; ntobc_a=1 
    346        CALL obc_read (nit000, nt_a, ntobc_a, iyyfile, immfile)  
    347        IF( lp_obc_east ) THEN 
    348           !  fills sfoe, tfoe, ufoe ,vfoe 
    349           sfoe(:,:) =  sedta (:,:,1) ; tfoe(:,:) =  tedta (:,:,1) 
    350           ufoe(:,:) =  uedta (:,:,1) ; vfoe(:,:) =  vedta (:,:,1) 
    351        ENDIF 
    352  
    353        IF( lp_obc_west) THEN 
    354           !  fills sfow, tfow, ufow ,vfow 
    355           sfow(:,:) =  swdta (:,:,1) ; tfow(:,:) =  twdta (:,:,1) 
    356           ufow(:,:) =  uwdta (:,:,1) ; vfow(:,:) =  vwdta (:,:,1) 
    357        ENDIF 
    358  
    359        IF( lp_obc_north) THEN 
    360           !  fills sfon, tfon, ufon ,vfon 
    361           sfon(:,:) =  sndta (:,:,1) ; tfon(:,:) =  tndta (:,:,1) 
    362           ufon(:,:) =  undta (:,:,1) ; vfon(:,:) =  vndta (:,:,1) 
    363        ENDIF 
    364  
    365        IF( lp_obc_south) THEN 
    366           !  fills sfos, tfos, ufos ,vfos 
    367           sfos(:,:) =  ssdta (:,:,1) ; tfos(:,:) =  tsdta (:,:,1) 
    368           ufos(:,:) =  usdta (:,:,1) ; vfos(:,:) =  vsdta (:,:,1) 
    369        ENDIF 
    370        RETURN  ! we go out of obc_dta_ini -------------------------------------->>>>> 
    371     ENDIF 
    372  
    373     ! nday_year is the day number in the current year ( 1 for 01/01 ) 
    374     ! we suppose that we always start from the begining of a day 
    375     !    zsec=MOD( (kt-nit000)*rdt - (nday_year - nday_year0 )*rday, rday ) ! number of seconds in the current day 
    376     zsec=0.e0  ! here, kt=nit000, nday_year = ndat_year0  
    377  
    378     IF (ln_obc_clim)  THEN  
    379       zjcnes = nday_year - 1  + zsec/rday  ! for clim file time is in days in a year 
    380     ELSE 
    381       zjcnes = ndate0_cnes + (nday_year - nday_year0 ) + zsec/rday 
    382     ENDIF 
    383  
    384     ! look for 'before' record number in the current file 
    385     ntobc = nrecbef () 
    386  
    387     IF (lwp) WRITE(numout,*) 'obc files frequency :',cffile 
    388     IF (lwp) WRITE(numout,*) ' zjcnes0 =',zjcnes,' ndastp0 =',ndastp 
    389     IF (lwp) WRITE(numout,*) ' annee0 ',iyy,' month0 ', imm,' day0 ', idd 
    390     IF (lwp) WRITE(numout,*) 'first file open :',cl_obc_nTS 
    391  
    392     ! record initialisation 
    393     !-------------------- 
    394     nt_b = 1 ; nt_a = 2 
    395  
    396     ntobc_a = ntobc + 1 
    397     ntobc_b = ntobc 
    398  
    399     CALL obc_read (kt, nt_b, ntobc_b, iyyfile, immfile)  ! read 'before' fields 
    400     CALL obc_read (kt, nt_a, ntobc_a, iyyfile, immfile)  ! read 'after' fields 
    401  
    402     zjcnes_obc(nt_b)= ztcobc(ntobc_b) 
    403     zjcnes_obc(nt_a)= ztcobc(ntobc_a) 
    404     !  
    405   END SUBROUTINE obc_dta_ini 
    406  
    407  
    408   SUBROUTINE obc_dta_chktime (kyyfile, kmmfile) 
    409    ! 
    410    ! check the number of time steps in the files and read ztcobc  
    411    ! 
    412    ! * Arguments 
    413    INTEGER, INTENT(in) :: kyyfile, kmmfile 
    414    ! * local variables 
    415    INTEGER :: istop       ! error control 
    416    INTEGER :: ji          ! dummy loop index 
    417  
    418     INTEGER ::  idvar, id_e, id_w, id_n, id_s, id_x       ! file identifiers 
    419     INTEGER, DIMENSION(1)  :: itmp 
    420     CHARACTER(LEN=25) :: cl_vname 
    421  
    422     ntobc_a = 0; itobce =0 ; itobcw = 0; itobcn = 0; itobcs = 0 
    423     ! build file name 
    424     WRITE(cl_obc_eTS ,'("obc_east_TS_y",i4.4,"m",i2.2,".nc")'  ) kyyfile,kmmfile 
    425     WRITE(cl_obc_wTS ,'("obc_west_TS_y",i4.4,"m",i2.2,".nc")'  ) kyyfile,kmmfile 
    426     WRITE(cl_obc_nTS ,'("obc_north_TS_y",i4.4,"m",i2.2,".nc")' ) kyyfile,kmmfile 
    427     WRITE(cl_obc_sTS ,'("obc_south_TS_y",i4.4,"m",i2.2,".nc")' ) kyyfile,kmmfile 
    428  
    429     cl_vname = 'time_counter' 
    430     IF ( lp_obc_east ) THEN 
    431        CALL iom_open ( cl_obc_eTS , id_e ) 
    432        idvar = iom_varid( id_e, cl_vname, kdimsz = itmp ); itobce=itmp(1) 
    433     ENDIF 
    434     IF ( lp_obc_west ) THEN 
    435        CALL iom_open ( cl_obc_wTS , id_w ) 
    436        idvar = iom_varid( id_w, cl_vname, kdimsz = itmp ) ; itobcw=itmp(1) 
    437     ENDIF 
    438     IF ( lp_obc_north ) THEN 
    439        CALL iom_open ( cl_obc_nTS , id_n ) 
    440        idvar = iom_varid( id_n, cl_vname, kdimsz = itmp ) ; itobcn=itmp(1) 
    441     ENDIF 
    442     IF ( lp_obc_south ) THEN 
    443        CALL iom_open ( cl_obc_sTS , id_s ) 
    444        idvar = iom_varid( id_s, cl_vname, kdimsz = itmp ) ; itobcs=itmp(1) 
    445     ENDIF 
    446  
    447     itobc = MAX( itobce, itobcw, itobcn, itobcs ) 
    448     istop = 0 
    449     IF ( lp_obc_east  .AND. itobce /= itobc ) istop = istop+1  
    450     IF ( lp_obc_west  .AND. itobcw /= itobc ) istop = istop+1       
    451     IF ( lp_obc_north .AND. itobcn /= itobc ) istop = istop+1 
    452     IF ( lp_obc_south .AND. itobcs /= itobc ) istop = istop+1  
    453     nstop = nstop + istop 
    454  
    455     IF ( istop /=  0 )  THEN 
    456        WRITE(ctmp1,*) ' east, west, north, south: ', itobce, itobcw, itobcn, itobcs 
    457        CALL ctl_stop( 'obcdta : all files must have the same number of time steps', ctmp1 ) 
    458     ENDIF 
    459  
    460     IF ( itobc == 1 ) THEN  
    461        IF (lwp) THEN 
    462           WRITE(numout,*) ' obcdta found one time step only in the OBC files' 
    463           IF (ln_obc_clim) THEN 
    464              ! OK no problem 
    465           ELSE 
    466              ln_obc_clim=.true. 
    467              WRITE(numout,*) ' we force ln_obc_clim to T' 
    468           ENDIF 
    469        ENDIF 
    470     ELSE 
    471 #if defined key_agrif 
    472        IF ( ASSOCIATED(ztcobc) ) DEALLOCATE ( ztcobc ) 
    473 #else 
    474        IF ( ALLOCATED(ztcobc) ) DEALLOCATE ( ztcobc ) 
    475 #endif 
    476        ALLOCATE (ztcobc(itobc)) 
    477        DO ji=1,1   ! use a dummy loop to read ztcobc only once 
    478           IF ( lp_obc_east ) THEN 
    479              CALL iom_gettime ( id_e, ztcobc, cl_vname ) ; CALL iom_close (id_e) ; EXIT 
    480           ENDIF 
    481           IF ( lp_obc_west ) THEN 
    482              CALL iom_gettime ( id_w, ztcobc, cl_vname ) ; CALL iom_close (id_w) ; EXIT 
    483           ENDIF 
    484           IF ( lp_obc_north ) THEN 
    485              CALL iom_gettime ( id_n, ztcobc, cl_vname ) ; CALL iom_close (id_n) ; EXIT 
    486           ENDIF 
    487           IF ( lp_obc_south ) THEN 
    488              CALL iom_gettime ( id_s, ztcobc, cl_vname ) ; CALL iom_close (id_s) ; EXIT 
    489           ENDIF 
    490        END DO 
    491        rdt_obc = ztcobc(2)-ztcobc(1)  !  just an information, not used for any computation 
    492        IF (lwp) WRITE(numout,*) ' obcdta found', itobc,' time steps in the OBC files' 
    493        IF (lwp) WRITE(numout,*) ' time step of obc data :', rdt_obc,' days'             
    494      ENDIF 
    495      zjcnes = zjcnes - rdt/rday  ! trick : zcnes is always incremented by rdt/rday in obc_dta! 
    496   END SUBROUTINE obc_dta_chktime 
    497  
    498  
    499 #if defined key_dynspg_ts || defined key_dynspg_exp 
    500   SUBROUTINE obc_dta_bt( kt, kbt ) 
    501     !!--------------------------------------------------------------------------- 
    502     !!                      ***  SUBROUTINE obc_dta  *** 
    503     !! 
    504     !! ** Purpose :   time interpolation of barotropic data for time-splitting scheme 
    505     !!                Data at the boundary must be in m2/s  
    506     !! 
    507     !! History : 
    508     !!   9.0  !  05-11 (V. garnier) Original code 
    509     !!--------------------------------------------------------------------------- 
    510     !! * Arguments 
    511     INTEGER, INTENT( in ) ::   kt          ! ocean time-step index 
    512     INTEGER, INTENT( in ) ::   kbt         ! barotropic ocean time-step index 
    513  
    514     !! * Local declarations 
    515     INTEGER ::   ji, jj, jk, ii, ij   ! dummy loop indices 
    516     INTEGER ::   id_e, id_w, id_n, id_s, fid  ! file identifiers 
    517     INTEGER ::   itimo, iman, imois, i15 
    518     INTEGER ::   itobcm, itobcp, itimom, itimop 
    519     REAL(wp) ::  zxy 
    520     INTEGER ::   isrel, ikt           ! number of seconds since 1/1/1992 
    521     INTEGER ::   iprint              ! frequency for printouts. 
    522  
    523     !!--------------------------------------------------------------------------- 
    524  
    525     ! 1.   First call: check time frames available in files. 
    526     ! ------------------------------------------------------- 
    527  
    528     IF( kt == nit000 ) THEN 
    529  
    530        ! 1.1  Barotropic tangential velocities set to zero 
    531        ! ------------------------------------------------- 
    532        IF( lp_obc_east  ) vbtfoe(:) = 0.e0 
    533        IF( lp_obc_west  ) vbtfow(:) = 0.e0 
    534        IF( lp_obc_south ) ubtfos(:) = 0.e0 
    535        IF( lp_obc_north ) ubtfon(:) = 0.e0 
    536  
    537        ! 1.2  Sea surface height and normal barotropic velocities set to zero 
    538        !                               or initial conditions if nobc_dta == 0 
    539        ! -------------------------------------------------------------------- 
    540  
    541        IF( lp_obc_east ) THEN 
    542           ! initialisation to zero 
    543           sshedta(:,:) = 0.e0 
    544           ubtedta(:,:) = 0.e0 
    545           !                                        ! ================== ! 
    546           IF( nobc_dta == 0 )   THEN               ! initial state used ! 
    547              !                                     ! ================== ! 
    548              !  Fills sedta, tedta, uedta (global arrays) 
    549              !  Remark: this works for njzoom = 1. Should the definition of ij include njzoom? 
    550              DO ji = nie0, nie1 
    551                 DO jj = nje0p1, nje1m1 
    552                    ij = jj -1 + njmpp 
    553                    sshedta(ij,1) = sshn(ji+1,jj) * tmask(ji+1,jj,1) 
    554                 END DO 
    555              END DO 
    556           ENDIF 
    557        ENDIF 
    558  
    559        IF( lp_obc_west) THEN 
    560           ! initialisation to zero 
    561           sshwdta(:,:) = 0.e0 
    562           ubtwdta(:,:) = 0.e0 
    563           !                                        ! ================== ! 
    564           IF( nobc_dta == 0 )   THEN               ! initial state used ! 
    565              !                                     ! ================== ! 
    566              !  Fills swdta, twdta, uwdta (global arrays) 
    567              !  Remark: this works for njzoom = 1. Should the definition of ij include njzoom? 
    568              DO ji = niw0, niw1 
    569                 DO jj = njw0p1, njw1m1 
    570                    ij = jj -1 + njmpp 
    571                    sshwdta(ij,1) = sshn(ji,jj) * tmask(ji,jj,1) 
    572                 END DO 
    573              END DO 
    574           ENDIF 
    575        ENDIF 
    576  
    577        IF( lp_obc_north) THEN 
    578           ! initialisation to zero 
    579           sshndta(:,:) = 0.e0 
    580           vbtndta(:,:) = 0.e0 
    581           !                                        ! ================== ! 
    582           IF( nobc_dta == 0 )   THEN               ! initial state used ! 
    583              !                                     ! ================== ! 
    584              !  Fills sndta, tndta, vndta (global arrays) 
    585              !  Remark: this works for njzoom = 1. Should the definition of ij include njzoom? 
    586              DO jj = njn0, njn1 
    587                 DO ji = nin0p1, nin1m1 
    588                    DO jk = 1, jpkm1 
    589                       ii = ji -1 + nimpp 
    590                       vbtndta(ii,1) = vbtndta(ii,1) + vndta(ii,jk,1)*fse3v(ji,jj,jk) 
    591                    END DO 
    592                    sshndta(ii,1) = sshn(ii,jj+1) * tmask(ji,jj+1,1) 
    593                 END DO 
    594              END DO 
    595           ENDIF 
    596        ENDIF 
    597  
    598        IF( lp_obc_south) THEN 
    599           ! initialisation to zero 
    600           ssdta(:,:,:) = 0.e0 
    601           tsdta(:,:,:) = 0.e0 
    602           vsdta(:,:,:) = 0.e0 
    603           sshsdta(:,:) = 0.e0 
    604           vbtsdta(:,:) = 0.e0 
    605           !                                        ! ================== ! 
    606           IF( nobc_dta == 0 )   THEN               ! initial state used ! 
    607              !                                     ! ================== ! 
    608              !  Fills ssdta, tsdta, vsdta (global arrays) 
    609              !  Remark: this works for njzoom = 1. Should the definition of ij include njzoom? 
    610              DO jj = njs0, njs1 
    611                 DO ji = nis0p1, nis1m1 
    612                    DO jk = 1, jpkm1 
    613                       ii = ji -1 + nimpp 
    614                       vbtsdta(ii,1) = vbtsdta(ii,1) + vsdta(ii,jk,1)*fse3v(ji,jj,jk) 
    615                    END DO 
    616                    sshsdta(ii,1) = sshn(ji,jj) * tmask(ii,jj,1) 
    617                 END DO 
    618              END DO 
    619           ENDIF 
    620        ENDIF 
    621  
    622     ENDIF        !       END IF kt == nit000 
    623  
    624     !!------------------------------------------------------------------------------------ 
    625     ! 2.      Initialize the time we are at. Does this every time the routine is called, 
    626     !         excepted when nobc_dta = 0 
    627     ! 
    628     IF( nobc_dta == 0) THEN 
    629        itimo = 1 
    630        zxy   = 0 
    631     ELSE 
    632        IF(ntobc == 1) THEN 
    633           itimo = 1 
    634        ELSE IF (ntobc == 12) THEN      !   BC are monthly 
    635           ! we assume we have climatology in that case 
    636           iman  = 12 
    637           i15   = nday / 16 
    638           imois = nmonth + i15 - 1 
    639           IF( imois == 0 )   imois = iman 
    640           itimo = imois 
    641        ELSE 
    642           IF(lwp) WRITE(numout,*) 'data other than constant or monthly',kt 
    643           iman  = ntobc 
    644           itimo = FLOOR( kt*rdt / tcobc(1)) 
    645           isrel=kt*rdt 
    646        ENDIF 
    647     ENDIF 
    648  
    649     ! 2. Read two records in the file if necessary 
    650     ! --------------------------------------------- 
    651  
    652     IF( nobc_dta == 1 .AND. nlecto == 1 ) THEN 
    653  
    654        IF( lp_obc_east ) THEN 
    655           ! ... Read datafile and set sea surface height and barotropic velocity 
    656           ! ... initialise the sshedta, ubtedta arrays 
    657           sshedta(:,0) = sshedta(:,1) 
    658           ubtedta(:,0) = ubtedta(:,1) 
    659           CALL iom_open ( 'obceast_TS.nc', id_e ) 
    660           CALL iom_get ( id_e, jpdom_unknown, 'vossurfh', sshedta(:,1), ktime=ntobc1 ) 
    661           CALL iom_get ( id_e, jpdom_unknown, 'vossurfh', sshedta(:,2), ktime=ntobc2 ) 
    662           IF( lk_dynspg_ts ) THEN 
    663              CALL iom_get (id_e, jpdom_unknown, 'vossurfh', sshedta(:,3), ktime=ntobc2+1 ) 
    664           ENDIF 
    665           CALL iom_close ( id_e ) 
    666           ! 
    667           CALL iom_open ( 'obceast_U.nc', id_e ) 
    668           CALL iom_get ( id_e, jpdom_unknown, 'vozoubt', ubtedta(:,1), ktime=ntobc1 ) 
    669           CALL iom_get ( id_e, jpdom_unknown, 'vozoubt', ubtedta(:,2), ktime=ntobc2 ) 
    670           IF( lk_dynspg_ts ) THEN 
    671              CALL iom_get ( id_e, jpdom_unknown, 'vozoubt', ubtedta(:,3), ktime=ntobc2+1 ) 
    672           ENDIF 
    673           CALL iom_close ( id_e ) 
    674           ! ... Usually printout is done only once at kt = nit000, unless nprint (namelist) > 1 
    675           IF( lwp .AND.  ( kt == nit000 .OR. nprint /= 0 )  ) THEN 
    676              WRITE(numout,*) 
    677              WRITE(numout,*) ' Read East OBC barotropic data records ', ntobc1, ntobc2 
    678              iprint = (jpjef-jpjed+1)/20 +1 
    679              WRITE(numout,*) 
    680              WRITE(numout,*) ' Sea surface height record 1' 
    681              CALL prihre( sshedta(:,1), jpjef-jpjed+1, 1, 1, jpjef-jpjed+1, iprint, 1, 1, -3, 1., numout ) 
    682              WRITE(numout,*) 
    683              WRITE(numout,*) ' Normal transport (m2/s) record 1',iprint 
    684              CALL prihre( ubtedta(:,1), jpjef-jpjed+1, 1, 1, jpjef-jpjed+1, iprint, 1, 1, -3, 1., numout ) 
    685           ENDIF 
    686        ENDIF 
    687  
    688        IF( lp_obc_west ) THEN 
    689           ! ... Read datafile and set temperature, salinity and normal velocity 
    690           ! ... initialise the swdta, twdta, uwdta arrays 
    691           sshwdta(:,0) = sshwdta(:,1) 
    692           ubtwdta(:,0) = ubtwdta(:,1) 
    693           CALL iom_open ( 'obcwest_TS.nc', id_w ) 
    694           CALL iom_get ( id_w, jpdom_unknown, 'vossurfh', sshwdta(:,1), ktime=ntobc1 ) 
    695           CALL iom_get ( id_w, jpdom_unknown, 'vossurfh', sshwdta(:,2), ktime=ntobc2 ) 
    696           IF( lk_dynspg_ts ) THEN 
    697              CALL  ( id_w, jpdom_unknown, 'vossurfh', sshwdta(:,3), ktime=ntobc2+1 ) 
    698           ENDIF 
    699           CALL iom_close ( id_w ) 
    700           ! 
    701           CALL iom_open ( 'obcwest_U.nc', id_w ) 
    702           CALL iom_get ( id_w, jpdom_unknown, 'vozoubt', ubtwdta(:,1), ktime=ntobc1 ) 
    703           CALL iom_get ( id_w, jpdom_unknown, 'vozoubt', ubtwdta(:,2), ktime=ntobc2 ) 
    704           IF( lk_dynspg_ts ) THEN 
    705              CALL iom_get ( id_w, jpdom_unknown, 'vozoubt', ubtwdta(:,3), ktime=ntobc2+1 ) 
    706           ENDIF 
    707           CALL iom_close ( id_w ) 
    708           ! ... Usually printout is done only once at kt = nit000, unless nprint (namelist) > 1 
    709           IF( lwp .AND.  ( kt == nit000 .OR. nprint /= 0 )  ) THEN 
    710              WRITE(numout,*) 
    711              WRITE(numout,*) ' Read West OBC barotropic data records ', ntobc1, ntobc2 
    712              iprint = (jpjwf-jpjwd+1)/20 +1 
    713              WRITE(numout,*) 
    714              WRITE(numout,*) ' Sea surface height record 1  - printout surface level' 
    715              CALL prihre( sshwdta(:,1), jpjwf-jpjwd+1, 1, 1, jpjwf-jpjwd+1, iprint, 1, 1, -3, 1., numout ) 
    716              WRITE(numout,*) 
    717              WRITE(numout,*) ' Normal transport (m2/s) record 1' 
    718              CALL prihre( ubtwdta(:,1), jpjwf-jpjwd+1, 1, 1, jpjwf-jpjwd+1, iprint, 1, 1, -3, 1., numout ) 
    719           ENDIF 
    720        ENDIF 
    721  
    722        IF( lp_obc_north) THEN 
    723           ! ... Read datafile and set sea surface height and barotropic velocity 
    724           ! ... initialise the sshndta, ubtndta arrays 
    725           sshndta(:,0) = sshndta(:,1) 
    726           vbtndta(:,0) = vbtndta(:,1) 
    727           CALL iom_open ( 'obcnorth_TS.nc', id_n ) 
    728           CALL iom_get (id_n, jpdom_unknown, 'vossurfh', sshndta(:,1), ktime=ntobc1 ) 
    729           CALL iom_get (id_n, jpdom_unknown, 'vossurfh', sshndta(:,2), ktime=ntobc2 ) 
    730           IF( lk_dynspg_ts ) THEN 
    731              CALL iom_get (id_n, jpdom_unknown, 'vossurfh', sshndta(:,3), ktime=ntobc2+1 ) 
    732           ENDIF 
    733           CALL iom_close ( id_n ) 
    734  
    735           CALL iom_open ( 'obcnorth_V.nc', id_n ) 
    736           CALL iom_get (id_n, jpdom_unknown, 'vomevbt', vbtndta(:,1), ktime=ntobc1 ) 
    737           CALL iom_get (id_n, jpdom_unknown, 'vomevbt', vbtndta(:,2), ktime=ntobc2 ) 
    738           IF( lk_dynspg_ts ) THEN 
    739              CALL iom_get (id_n, jpdom_unknown, 'vomevbt', vbtndta(:,3), ktime=ntobc2+1 ) 
    740           ENDIF 
    741           CALL iom_close ( id_n ) 
    742  
    743           ! ... Usually printout is done only once at kt = nit000, unless nprint (namelist) > 1 
    744           IF( lwp .AND.  ( kt == nit000 .OR. nprint /= 0 )  ) THEN 
    745              WRITE(numout,*) 
    746              WRITE(numout,*) ' Read North OBC barotropic data records ', ntobc1, ntobc2 
    747              iprint = (jpinf-jpind+1)/20 +1 
    748              WRITE(numout,*) 
    749              WRITE(numout,*) ' Sea surface height record 1  - printout surface level' 
    750              CALL prihre( sshndta(:,1), jpinf-jpind+1, 1, 1, jpinf-jpind+1, iprint, 1, 1, -3, 1., numout ) 
    751              WRITE(numout,*) 
    752              WRITE(numout,*) ' Normal transport (m2/s) record 1' 
    753              CALL prihre( vbtndta(:,1), jpinf-jpind+1, 1, 1, jpinf-jpind+1, iprint, 1, 1, -3, 1., numout ) 
    754           ENDIF 
    755        ENDIF 
    756  
    757        IF( lp_obc_south) THEN 
    758           ! ... Read datafile and set sea surface height and barotropic velocity 
    759           ! ... initialise the sshsdta, ubtsdta arrays 
    760           sshsdta(:,0) = sshsdta(:,1) 
    761           vbtsdta(:,0) = vbtsdta(:,1) 
    762           CALL iom_open ( 'obcsouth_TS.nc', id_s ) 
    763           CALL iom_get ( id_s, jpdom_unknown, 'vossurfh', sshsdta(:,1), ktime=ntobc1 ) 
    764           CALL iom_get ( id_s, jpdom_unknown, 'vossurfh', sshsdta(:,2), ktime=ntobc2 ) 
    765           IF( lk_dynspg_ts ) THEN 
    766              CALL iom_get ( id_s, jpdom_unknown, 'vossurfh', sshsdta(:,3), ktime=ntobc2+1 ) 
    767           ENDIF 
    768           CALL iom_close ( id_s ) 
    769  
    770           CALL iom_open ( 'obcsouth_V.nc', id_s ) 
    771           CALL iom_get ( id_s, jpdom_unknown, 'vomevbt', vbtsdta(:,1), ktime=ntobc1 ) 
    772           CALL iom_get ( id_s, jpdom_unknown, 'vomevbt', vbtsdta(:,2), ktime=ntobc2 ) 
    773           IF( lk_dynspg_ts ) THEN 
    774              CALL iom_get ( id_s, jpdom_unknown, 'vomevbt', vbtsdta(:,3), ktime=ntobc2+1 ) 
    775           ENDIF 
    776           CALL iom_close ( id_s ) 
    777  
    778           ! ... Usually printout is done only once at kt = nit000, unless nprint (namelist) > 1 
    779           IF( lwp .AND.  ( kt == nit000 .OR. nprint /= 0 )  ) THEN 
    780              WRITE(numout,*) 
    781              WRITE(numout,*) ' Read South OBC barotropic data records ', ntobc1, ntobc2 
    782              iprint = (jpisf-jpisd+1)/20 +1 
    783              WRITE(numout,*) 
    784              WRITE(numout,*) ' Sea surface height record 1  - printout surface level' 
    785              CALL prihre( sshsdta(:,1), jpisf-jpisd+1, 1, 1, jpisf-jpisd+1, iprint, 1, 1, -3, 1., numout ) 
    786              WRITE(numout,*) 
    787              WRITE(numout,*) ' Normal transport (m2/s) record 1' 
    788              CALL prihre( vbtsdta(:,1), jpisf-jpisd+1, 1, 1, jpisf-jpisd+1, iprint, 1, 1, -3, 1., numout ) 
    789           ENDIF 
    790        ENDIF 
    791  
    792     ENDIF        !      end of the test on the condition to read or not the files 
    793  
    794     ! 3.  Call at every time step : Linear interpolation of BCs to current time step 
    795     ! ---------------------------------------------------------------------- 
    796  
    797     IF( lk_dynspg_ts ) THEN 
    798        isrel = (kt-1)*rdt + kbt*(rdt/REAL(nn_baro,wp)) 
    799  
    800        IF( nobc_dta == 1 ) THEN 
    801           isrel = (kt-1)*rdt + kbt*(rdt/REAL(nn_baro,wp)) 
    802           itimo  = FLOOR(  kt*rdt    / (tcobc(2)-tcobc(1)) ) 
    803           itimom = FLOOR( (kt-1)*rdt / (tcobc(2)-tcobc(1)) ) 
    804           itimop = FLOOR( (kt+1)*rdt / (tcobc(2)-tcobc(1)) ) 
    805           IF( itimom == itimo .AND. itimop == itimo ) THEN 
    806              itobcm = ntobc1 
    807              itobcp = ntobc2 
    808  
    809           ELSEIF ( itimom <= itimo .AND. itimop == itimo ) THEN 
    810              IF(  FLOOR( isrel / (tcobc(2)-tcobc(1)) ) < itimo ) THEN 
    811                 itobcm = ntobc1-1 
    812                 itobcp = ntobc2-1 
    813              ELSE 
    814                 itobcm = ntobc1 
    815                 itobcp = ntobc2 
    816              ENDIF 
    817  
    818           ELSEIF ( itimom == itimo .AND. itimop >= itimo ) THEN 
    819              IF(  FLOOR( isrel / (tcobc(2)-tcobc(1)) ) < itimop ) THEN 
    820                 itobcm = ntobc1 
    821                 itobcp = ntobc2 
    822              ELSE 
    823                 itobcm = ntobc1+1 
    824                 itobcp = ntobc2+1 
    825              ENDIF 
    826  
    827           ELSEIF ( itimom == itimo-1 .AND. itimop == itimo+1 ) THEN 
    828              IF(  FLOOR( isrel / (tcobc(2)-tcobc(1)) ) < itimo ) THEN 
    829                 itobcm = ntobc1-1 
    830                 itobcp = ntobc2-1 
    831              ELSEIF (  FLOOR( isrel / (tcobc(2)-tcobc(1)) ) < itimop ) THEN 
    832                 itobcm = ntobc1 
    833                 itobcp = ntobc2 
    834              ELSEIF (  FLOOR( isrel / (tcobc(2)-tcobc(1)) ) == itimop ) THEN 
    835                 itobcm = ntobc1+1 
    836                 itobcp = ntobc2+2 
    837              ELSE 
    838                 IF(lwp) WRITE(numout, *) 'obc_dta_bt: You should not have seen this print! error 1?' 
    839              ENDIF 
    840           ELSE 
    841              IF(lwp) WRITE(numout, *) 'obc_dta_bt: You should not have seen this print! error 2?' 
    842           ENDIF 
    843  
    844        ENDIF 
    845  
    846     ELSE IF( lk_dynspg_exp ) THEN 
    847        isrel=kt*rdt 
    848        itobcm = ntobc1 
    849        itobcp = ntobc2 
    850     ENDIF 
    851  
    852     IF( ntobc == 1 .OR. nobc_dta == 0 ) THEN 
    853        zxy = 0.e0 
    854     ELSE IF( ntobc == 12 ) THEN 
    855        zxy = FLOAT( nday + 15 - 30 * i15 ) / 30. 
    856     ELSE 
    857        zxy = (tcobc(itobcm)-FLOAT(isrel)) / (tcobc(itobcm)-tcobc(itobcp)) 
    858     ENDIF 
    859  
    860     IF( lp_obc_east ) THEN           !  fills sshfoe, ubtfoe (local to each processor) 
    861        DO jj = nje0p1, nje1m1 
    862           ij = jj -1 + njmpp 
    863           sshfoe(jj) = ( zxy * sshedta(ij,2) + (1.-zxy) * sshedta(ij,1) ) * temsk(jj,1) 
    864           ubtfoe(jj) = ( zxy * ubtedta(ij,2) + (1.-zxy) * ubtedta(ij,1) ) * uemsk(jj,1) 
    865        END DO 
    866     ENDIF 
    867  
    868     IF( lp_obc_west) THEN            !  fills sshfow, ubtfow (local to each processor) 
    869        DO jj = njw0p1, njw1m1 
    870           ij = jj -1 + njmpp 
    871           sshfow(jj) = ( zxy * sshwdta(ij,2) + (1.-zxy) * sshwdta(ij,1) ) * twmsk(jj,1) 
    872           ubtfow(jj) = ( zxy * ubtwdta(ij,2) + (1.-zxy) * ubtwdta(ij,1) ) * uwmsk(jj,1) 
    873        END DO 
    874     ENDIF 
    875  
    876     IF( lp_obc_north) THEN           !  fills sshfon, vbtfon (local to each processor) 
    877        DO ji = nin0p1, nin1m1 
    878           ii = ji -1 + nimpp 
    879           sshfon(ji) = ( zxy * sshndta(ii,2) + (1.-zxy) * sshndta(ii,1) ) * tnmsk(ji,1) 
    880           vbtfon(ji) = ( zxy * vbtndta(ii,2) + (1.-zxy) * vbtndta(ii,1) ) * vnmsk(ji,1) 
    881        END DO 
    882     ENDIF 
    883  
    884     IF( lp_obc_south) THEN           !  fills sshfos, vbtfos (local to each processor) 
    885        DO ji = nis0p1, nis1m1 
    886           ii = ji -1 + nimpp 
    887           sshfos(ji) = ( zxy * sshsdta(ii,2) + (1.-zxy) * sshsdta(ii,1) ) * tsmsk(ji,1) 
    888           vbtfos(ji) = ( zxy * vbtsdta(ii,2) + (1.-zxy) * vbtsdta(ii,1) ) * vsmsk(ji,1) 
    889        END DO 
    890     ENDIF 
    891  
    892   END SUBROUTINE obc_dta_bt 
    893  
    894 #else 
    895   !!----------------------------------------------------------------------------- 
    896   !!   Default option 
    897   !!----------------------------------------------------------------------------- 
    898   SUBROUTINE obc_dta_bt ( kt, kbt )       ! Empty routine 
    899     !! * Arguments 
    900     INTEGER,INTENT(in) :: kt 
    901     INTEGER, INTENT( in ) ::   kbt         ! barotropic ocean time-step index 
    902     WRITE(*,*) 'obc_dta_bt: You should not have seen this print! error?', kt 
    903     WRITE(*,*) 'obc_dta_bt: You should not have seen this print! error?', kbt 
    904   END SUBROUTINE obc_dta_bt 
    905 #endif 
    906  
    907  
    908   !!============================================================================== 
    909   SUBROUTINE obc_read (kt, nt_x, ntobc_x, iyy, imm) 
    910      !!------------------------------------------------------------------------- 
    911      !!                      ***  ROUTINE obc_read  *** 
    912      !! 
    913      !! ** Purpose :  Read the boundary data in files identified by iyy and imm 
    914      !!               According to the validated open boundaries, return the  
    915      !!               following arrays : 
    916      !!                sedta, tedta : East OBC salinity and temperature 
    917      !!                uedta, vedta :   "   "  u and v velocity component       
    918      !! 
    919      !!                swdta, twdta : West OBC salinity and temperature 
    920      !!                uwdta, vwdta :   "   "  u and v velocity component       
    921      !! 
    922      !!                sndta, tndta : North OBC salinity and temperature 
    923      !!                undta, vndta :   "   "  u and v velocity component       
    924      !! 
    925      !!                ssdta, tsdta : South OBC salinity and temperature 
    926      !!                usdta, vsdta :   "   "  u and v velocity component       
    927      !! 
    928      !! ** Method  :  These fields are read in the record ntobc_x of the files. 
    929      !!               The number of records is already known. If  ntobc_x is greater 
    930      !!               than the number of record, this routine will look for next file, 
    931      !!               updating the indices (case of inter-annual obcs) or loop at the 
    932      !!               begining in case of climatological file (ln_obc_clim = true ). 
    933      !! ------------------------------------------------------------------------- 
    934      !! History:     !  2005  ( P. Mathiot, C. Langlais ) Original code 
    935      !!              !  2008  ( J,M, Molines ) Use IOM and cleaning 
    936      !!-------------------------------------------------------------------------- 
    937  
    938     ! * Arguments 
    939     INTEGER, INTENT( in ) :: kt, nt_x 
    940     INTEGER, INTENT( inout ) :: ntobc_x , iyy, imm      ! yes ! inout ! 
    941  
    942     ! * Local variables 
    943     CHARACTER (len=40) :: &    ! file names 
     314      ! all logical-mask are initialzed to true when declared 
     315      WHERE ( temsk == 0 ) ltemsk=.FALSE.  
     316      WHERE ( uemsk == 0 ) luemsk=.FALSE.  
     317      WHERE ( vemsk == 0 ) lvemsk=.FALSE.  
     318 
     319      WHERE ( twmsk == 0 ) ltwmsk=.FALSE.  
     320      WHERE ( uwmsk == 0 ) luwmsk=.FALSE.  
     321      WHERE ( vwmsk == 0 ) lvwmsk=.FALSE.  
     322 
     323      WHERE ( tnmsk == 0 ) ltnmsk=.FALSE.  
     324      WHERE ( unmsk == 0 ) lunmsk=.FALSE.  
     325      WHERE ( vnmsk == 0 ) lvnmsk=.FALSE.  
     326 
     327      WHERE ( tsmsk == 0 ) ltsmsk=.FALSE.  
     328      WHERE ( usmsk == 0 ) lusmsk=.FALSE.  
     329      WHERE ( vsmsk == 0 ) lvsmsk=.FALSE.  
     330 
     331      iyear=1950;  imonth=01; iday=01;  zsec=0.  
     332      ! zjuliancnes : julian day corresonding  to  01/01/1950 
     333      CALL ymds2ju(iyear, imonth, iday,zsec , zjuliancnes) 
     334 
     335      !current year and curent month  
     336      iyy=INT(ndastp/10000) ; imm=INT((ndastp -iyy*10000)/100) ; idd=(ndastp-iyy*10000-imm*100) 
     337      IF (iyy <  1900)  iyy = iyy+1900  ! always assume that years are on 4 digits. 
     338      CALL ymds2ju(iyy, imm, idd ,zsec , zjulian) 
     339      ndate0_cnes = zjulian - zjuliancnes   ! jcnes day when call to obc_dta_ini 
     340 
     341      iyyfile=iyy ; immfile=0  ! set component of the current file name 
     342      IF ( cffile /= 'annual') immfile=imm 
     343      IF ( ln_obc_clim) iyyfile = 0  ! assume that climatological files are labeled y0000 
     344 
     345      CALL obc_dta_chktime ( iyyfile, immfile ) 
     346 
     347      IF ( itobc == 1 ) THEN  
     348         ! in this case we will provide boundary data only once. 
     349         nt_a=1 ; ntobc_a=1 
     350         CALL obc_read (nit000, nt_a, ntobc_a, iyyfile, immfile)  
     351         IF( lp_obc_east ) THEN 
     352            !  fills sfoe, tfoe, ufoe ,vfoe 
     353            sfoe(:,:) =  sedta (:,:,1) ; tfoe(:,:) =  tedta (:,:,1) 
     354            ufoe(:,:) =  uedta (:,:,1) ; vfoe(:,:) =  vedta (:,:,1) 
     355         ENDIF 
     356 
     357         IF( lp_obc_west) THEN 
     358            !  fills sfow, tfow, ufow ,vfow 
     359            sfow(:,:) =  swdta (:,:,1) ; tfow(:,:) =  twdta (:,:,1) 
     360            ufow(:,:) =  uwdta (:,:,1) ; vfow(:,:) =  vwdta (:,:,1) 
     361         ENDIF 
     362 
     363         IF( lp_obc_north) THEN 
     364            !  fills sfon, tfon, ufon ,vfon 
     365            sfon(:,:) =  sndta (:,:,1) ; tfon(:,:) =  tndta (:,:,1) 
     366            ufon(:,:) =  undta (:,:,1) ; vfon(:,:) =  vndta (:,:,1) 
     367         ENDIF 
     368 
     369         IF( lp_obc_south) THEN 
     370            !  fills sfos, tfos, ufos ,vfos 
     371            sfos(:,:) =  ssdta (:,:,1) ; tfos(:,:) =  tsdta (:,:,1) 
     372            ufos(:,:) =  usdta (:,:,1) ; vfos(:,:) =  vsdta (:,:,1) 
     373         ENDIF 
     374         RETURN  ! we go out of obc_dta_ini -------------------------------------->>>>> 
     375      ENDIF 
     376 
     377      ! nday_year is the day number in the current year ( 1 for 01/01 ) 
     378      ! we suppose that we always start from the begining of a day 
     379      !    zsec=MOD( (kt-nit000)*rdt - (nday_year - nday_year0 )*rday, rday ) ! number of seconds in the current day 
     380      zsec=0.e0  ! here, kt=nit000, nday_year = ndat_year0  
     381 
     382      IF (ln_obc_clim)  THEN  
     383         zjcnes = nday_year - 1  + zsec/rday  ! for clim file time is in days in a year 
     384      ELSE 
     385         zjcnes = ndate0_cnes + (nday_year - nday_year0 ) + zsec/rday 
     386      ENDIF 
     387 
     388      ! look for 'before' record number in the current file 
     389      ntobc = nrecbef () 
     390 
     391      IF (lwp) WRITE(numout,*) 'obc files frequency :',cffile 
     392      IF (lwp) WRITE(numout,*) ' zjcnes0 =',zjcnes,' ndastp0 =',ndastp 
     393      IF (lwp) WRITE(numout,*) ' annee0 ',iyy,' month0 ', imm,' day0 ', idd 
     394      IF (lwp) WRITE(numout,*) 'first file open :',cl_obc_nTS 
     395 
     396      ! record initialisation 
     397      !-------------------- 
     398      nt_b = 1 ; nt_a = 2 
     399 
     400      ntobc_a = ntobc + 1 
     401      ntobc_b = ntobc 
     402 
     403      CALL obc_read (kt, nt_b, ntobc_b, iyyfile, immfile)  ! read 'before' fields 
     404      CALL obc_read (kt, nt_a, ntobc_a, iyyfile, immfile)  ! read 'after' fields 
     405 
     406      ! additional frame in case of time-splitting 
     407# if defined key_dynspg_ts 
     408      nt_m = 0 
     409      ntobc_m=mod(ntobc_b-2+itobc,itobc)+1 
     410      zjcnes_obc(nt_m)= ztcobc(ntobc_m) ! FDbug has not checked that this is correct!! 
     411      IF (ln_rstart) THEN 
     412         CALL obc_read (kt, nt_m, ntobc_m, iyyfile, immfile)  ! read 'after' fields 
     413      ENDIF 
     414# endif 
     415 
     416      zjcnes_obc(nt_b)= ztcobc(ntobc_b) 
     417      zjcnes_obc(nt_a)= ztcobc(ntobc_a) 
     418      !  
     419   END SUBROUTINE obc_dta_ini 
     420 
     421 
     422   SUBROUTINE obc_dta_chktime (kyyfile, kmmfile) 
     423      ! 
     424      ! check the number of time steps in the files and read ztcobc  
     425      ! 
     426      ! * Arguments 
     427      INTEGER, INTENT(in) :: kyyfile, kmmfile 
     428      ! * local variables 
     429      INTEGER :: istop       ! error control 
     430      INTEGER :: ji          ! dummy loop index 
     431 
     432      INTEGER ::  idvar, id_e, id_w, id_n, id_s       ! file identifiers 
     433      INTEGER, DIMENSION(1)  :: itmp 
     434      CHARACTER(LEN=25) :: cl_vname 
     435 
     436      ntobc_a = 0; itobce =0 ; itobcw = 0; itobcn = 0; itobcs = 0 
     437      ! build file name 
     438      IF(ln_obc_clim) THEN   ! revert to old convention for climatological OBC forcing 
     439         cl_obc_eTS='obceast_TS.nc' 
     440         cl_obc_wTS='obcwest_TS.nc' 
     441         cl_obc_nTS='obcnorth_TS.nc' 
     442         cl_obc_sTS='obcsouth_TS.nc' 
     443      ELSE                   ! convention for climatological OBC 
     444         WRITE(cl_obc_eTS ,'("obc_east_TS_y",i4.4,"m",i2.2,".nc")'  ) kyyfile,kmmfile 
     445         WRITE(cl_obc_wTS ,'("obc_west_TS_y",i4.4,"m",i2.2,".nc")'  ) kyyfile,kmmfile 
     446         WRITE(cl_obc_nTS ,'("obc_north_TS_y",i4.4,"m",i2.2,".nc")' ) kyyfile,kmmfile 
     447         WRITE(cl_obc_sTS ,'("obc_south_TS_y",i4.4,"m",i2.2,".nc")' ) kyyfile,kmmfile 
     448      ENDIF 
     449 
     450      cl_vname = 'time_counter' 
     451      IF ( lp_obc_east ) THEN 
     452         CALL iom_open ( cl_obc_eTS , id_e ) 
     453         idvar = iom_varid( id_e, cl_vname, kdimsz = itmp ); itobce=itmp(1) 
     454      ENDIF 
     455      IF ( lp_obc_west ) THEN 
     456         CALL iom_open ( cl_obc_wTS , id_w ) 
     457         idvar = iom_varid( id_w, cl_vname, kdimsz = itmp ) ; itobcw=itmp(1) 
     458      ENDIF 
     459      IF ( lp_obc_north ) THEN 
     460         CALL iom_open ( cl_obc_nTS , id_n ) 
     461         idvar = iom_varid( id_n, cl_vname, kdimsz = itmp ) ; itobcn=itmp(1) 
     462      ENDIF 
     463      IF ( lp_obc_south ) THEN 
     464         CALL iom_open ( cl_obc_sTS , id_s ) 
     465         idvar = iom_varid( id_s, cl_vname, kdimsz = itmp ) ; itobcs=itmp(1) 
     466      ENDIF 
     467 
     468      itobc = MAX( itobce, itobcw, itobcn, itobcs ) 
     469      istop = 0 
     470      IF ( lp_obc_east  .AND. itobce /= itobc ) istop = istop+1  
     471      IF ( lp_obc_west  .AND. itobcw /= itobc ) istop = istop+1       
     472      IF ( lp_obc_north .AND. itobcn /= itobc ) istop = istop+1 
     473      IF ( lp_obc_south .AND. itobcs /= itobc ) istop = istop+1  
     474      nstop = nstop + istop 
     475 
     476      IF ( istop /=  0 )  THEN 
     477         WRITE(ctmp1,*) ' east, west, north, south: ', itobce, itobcw, itobcn, itobcs 
     478         CALL ctl_stop( 'obcdta : all files must have the same number of time steps', ctmp1 ) 
     479      ENDIF 
     480 
     481      IF ( itobc == 1 ) THEN  
     482         IF (lwp) THEN 
     483            WRITE(numout,*) ' obcdta found one time step only in the OBC files' 
     484            IF (ln_obc_clim) THEN 
     485               ! OK no problem 
     486            ELSE 
     487               ln_obc_clim=.true. 
     488               WRITE(numout,*) ' we force ln_obc_clim to T' 
     489            ENDIF 
     490         ENDIF 
     491      ELSE 
     492         IF ( ALLOCATED(ztcobc) ) DEALLOCATE ( ztcobc ) 
     493         ALLOCATE (ztcobc(itobc)) 
     494         DO ji=1,1   ! use a dummy loop to read ztcobc only once 
     495            IF ( lp_obc_east ) THEN 
     496               CALL iom_gettime ( id_e, ztcobc, cl_vname ) ; CALL iom_close (id_e) ; EXIT 
     497            ENDIF 
     498            IF ( lp_obc_west ) THEN 
     499               CALL iom_gettime ( id_w, ztcobc, cl_vname ) ; CALL iom_close (id_w) ; EXIT 
     500            ENDIF 
     501            IF ( lp_obc_north ) THEN 
     502               CALL iom_gettime ( id_n, ztcobc, cl_vname ) ; CALL iom_close (id_n) ; EXIT 
     503            ENDIF 
     504            IF ( lp_obc_south ) THEN 
     505               CALL iom_gettime ( id_s, ztcobc, cl_vname ) ; CALL iom_close (id_s) ; EXIT 
     506            ENDIF 
     507         END DO 
     508         rdt_obc = ztcobc(2)-ztcobc(1)  !  just an information, not used for any computation 
     509         IF (lwp) WRITE(numout,*) ' obcdta found', itobc,' time steps in the OBC files' 
     510         IF (lwp) WRITE(numout,*) ' time step of obc data :', rdt_obc,' days'             
     511      ENDIF 
     512      zjcnes = zjcnes - rdt/rday  ! trick : zcnes is always incremented by rdt/rday in obc_dta! 
     513   END SUBROUTINE obc_dta_chktime 
     514 
     515# if defined key_dynspg_ts || defined key_dynspg_exp 
     516   SUBROUTINE obc_dta_bt( kt, kbt ) 
     517      !!--------------------------------------------------------------------------- 
     518      !!                      ***  SUBROUTINE obc_dta  *** 
     519      !! 
     520      !! ** Purpose :   time interpolation of barotropic data for time-splitting scheme 
     521      !!                Data at the boundary must be in m2/s  
     522      !! 
     523      !! History : 
     524      !!   9.0  !  05-11 (V. garnier) Original code 
     525      !!--------------------------------------------------------------------------- 
     526      !! * Arguments 
     527      INTEGER, INTENT( in ) ::   kt          ! ocean time-step index 
     528      INTEGER, INTENT( in ) ::   kbt         ! barotropic ocean time-step index 
     529 
     530      !! * Local declarations 
     531      INTEGER ::   ji, jj  ! dummy loop indices 
     532      INTEGER ::   i15 
     533      INTEGER ::   itobcm, itobcp 
     534      REAL(wp) ::  zxy 
     535      INTEGER ::   isrel           ! number of seconds since 1/1/1992 
     536 
     537      !!--------------------------------------------------------------------------- 
     538 
     539      ! 1.   First call: check time frames available in files. 
     540      ! ------------------------------------------------------- 
     541 
     542      IF( kt == nit000 ) THEN 
     543 
     544         ! 1.1  Barotropic tangential velocities set to zero 
     545         ! ------------------------------------------------- 
     546         IF( lp_obc_east  ) vbtfoe(:) = 0.e0 
     547         IF( lp_obc_west  ) vbtfow(:) = 0.e0 
     548         IF( lp_obc_south ) ubtfos(:) = 0.e0 
     549         IF( lp_obc_north ) ubtfon(:) = 0.e0 
     550 
     551         ! 1.2  Sea surface height and normal barotropic velocities set to zero 
     552         !                               or initial conditions if nobc_dta == 0 
     553         ! -------------------------------------------------------------------- 
     554 
     555         IF( lp_obc_east ) THEN 
     556            ! initialisation to zero 
     557            sshedta(:,:) = 0.e0 
     558            ubtedta(:,:) = 0.e0 
     559            vbtedta(:,:) = 0.e0 ! tangential component 
     560            !                                        ! ================== ! 
     561            IF( nobc_dta == 0 )   THEN               ! initial state used ! 
     562               !                                     ! ================== ! 
     563               !  Fills sedta, tedta, uedta (global arrays) 
     564               !  Remark: this works for njzoom = 1. Should the definition of ij include njzoom? 
     565               DO ji = nie0, nie1 
     566                  DO jj = 1, jpj 
     567                     sshedta(jj,1) = sshn(ji+1,jj) * tmask(ji+1,jj,1) 
     568                  END DO 
     569               END DO 
     570            ENDIF 
     571         ENDIF 
     572 
     573         IF( lp_obc_west) THEN 
     574            ! initialisation to zero 
     575            sshwdta(:,:) = 0.e0 
     576            ubtwdta(:,:) = 0.e0 
     577            vbtwdta(:,:) = 0.e0 ! tangential component 
     578            !                                        ! ================== ! 
     579            IF( nobc_dta == 0 )   THEN               ! initial state used ! 
     580               !                                     ! ================== ! 
     581               !  Fills swdta, twdta, uwdta (global arrays) 
     582               !  Remark: this works for njzoom = 1. Should the definition of ij include njzoom? 
     583               DO ji = niw0, niw1 
     584                  DO jj = 1, jpj 
     585                     sshwdta(jj,1) = sshn(ji,jj) * tmask(ji,jj,1) 
     586                  END DO 
     587               END DO 
     588            ENDIF 
     589         ENDIF 
     590 
     591         IF( lp_obc_north) THEN 
     592            ! initialisation to zero 
     593            sshndta(:,:) = 0.e0 
     594            ubtndta(:,:) = 0.e0 ! tangential component 
     595            vbtndta(:,:) = 0.e0 
     596            !                                        ! ================== ! 
     597            IF( nobc_dta == 0 ) THEN                 ! initial state used ! 
     598               !                                     ! ================== ! 
     599               !  Fills sndta, tndta, vndta (global arrays) 
     600               !  Remark: this works for njzoom = 1. Should the definition of ij include njzoom? 
     601               DO jj = njn0, njn1 
     602                  DO ji = 1, jpi 
     603                     sshndta(ji,1) = sshn(ji,jj+1) * tmask(ji,jj+1,1) 
     604                  END DO 
     605               END DO 
     606            ENDIF 
     607         ENDIF 
     608 
     609         IF( lp_obc_south) THEN 
     610            ! initialisation to zero 
     611            sshsdta(:,:) = 0.e0 
     612            ubtsdta(:,:) = 0.e0 ! tangential component 
     613            vbtsdta(:,:) = 0.e0 
     614            !                                        ! ================== ! 
     615            IF( nobc_dta == 0 )   THEN               ! initial state used ! 
     616               !                                     ! ================== ! 
     617               !  Fills ssdta, tsdta, vsdta (global arrays) 
     618               !  Remark: this works for njzoom = 1. Should the definition of ij include njzoom? 
     619               DO jj = njs0, njs1 
     620                  DO ji = 1, jpi 
     621                     sshsdta(ji,1) = sshn(ji,jj) * tmask(ji,jj,1) 
     622                  END DO 
     623               END DO 
     624            ENDIF 
     625         ENDIF 
     626 
     627         IF( nobc_dta == 0 ) CALL obc_depth_average(1)   ! depth averaged velocity from the OBC depth-dependent frames 
     628 
     629      ENDIF        !       END kt == nit000 
     630 
     631      !!------------------------------------------------------------------------------------ 
     632      ! 2.      Initialize the time we are at. Does this every time the routine is called, 
     633      !         excepted when nobc_dta = 0 
     634      ! 
     635 
     636      ! 3.  Call at every time step : Linear interpolation of BCs to current time step 
     637      ! ---------------------------------------------------------------------- 
     638 
     639      IF( lk_dynspg_ts ) THEN 
     640         isrel = (kt-1)*rdt + kbt*(rdt/REAL(nn_baro,wp)) 
     641      ELSE IF( lk_dynspg_exp ) THEN 
     642         isrel=kt*rdt 
     643      ENDIF 
     644 
     645      itobcm = nt_b 
     646      itobcp = nt_a 
     647      IF( itobc == 1 .OR. nobc_dta == 0 ) THEN 
     648         zxy = 0.e0 
     649         itobcm = 1 
     650         itobcp = 1 
     651      ELSE IF( itobc == 12 ) THEN 
     652         i15   = nday / 16 
     653         zxy = FLOAT( nday + 15 - 30 * i15 ) / 30. 
     654      ELSE 
     655         zxy = (zjcnes_obc(nt_a)-FLOAT(isrel)) / (zjcnes_obc(nt_a)-zjcnes_obc(nt_b)) 
     656         IF( zxy < 0. ) THEN   ! case of extrapolation, switch to old time frames 
     657            itobcm = nt_m 
     658            itobcp = nt_b 
     659            zxy = (zjcnes_obc(nt_b)-FLOAT(isrel)) / (zjcnes_obc(nt_b)-zjcnes_obc(nt_m)) 
     660         ENDIF 
     661      ENDIF 
     662 
     663      IF( lp_obc_east ) THEN           !  fills sshfoe, ubtfoe (local to each processor) 
     664         DO jj = 1, jpj 
     665            sshfoe(jj) = zxy * sshedta(jj,itobcp) + (1.-zxy) * sshedta(jj,itobcm) 
     666            ubtfoe(jj) = zxy * ubtedta(jj,itobcp) + (1.-zxy) * ubtedta(jj,itobcm) 
     667            vbtfoe(jj) = zxy * vbtedta(jj,itobcp) + (1.-zxy) * vbtedta(jj,itobcm) 
     668         END DO 
     669      ENDIF 
     670 
     671      IF( lp_obc_west) THEN            !  fills sshfow, ubtfow (local to each processor) 
     672         DO jj = 1, jpj 
     673            sshfow(jj) = zxy * sshwdta(jj,itobcp) + (1.-zxy) * sshwdta(jj,itobcm) 
     674            ubtfow(jj) = zxy * ubtwdta(jj,itobcp) + (1.-zxy) * ubtwdta(jj,itobcm) 
     675            vbtfow(jj) = zxy * vbtwdta(jj,itobcp) + (1.-zxy) * vbtwdta(jj,itobcm) 
     676         END DO 
     677      ENDIF 
     678 
     679      IF( lp_obc_north) THEN           !  fills sshfon, vbtfon (local to each processor) 
     680         DO ji = 1, jpi 
     681            sshfon(ji) = zxy * sshndta(ji,itobcp) + (1.-zxy) * sshndta(ji,itobcm) 
     682            ubtfon(ji) = zxy * ubtndta(ji,itobcp) + (1.-zxy) * ubtndta(ji,itobcm) 
     683            vbtfon(ji) = zxy * vbtndta(ji,itobcp) + (1.-zxy) * vbtndta(ji,itobcm) 
     684         END DO 
     685      ENDIF 
     686 
     687      IF( lp_obc_south) THEN           !  fills sshfos, vbtfos (local to each processor) 
     688         DO ji = 1, jpi 
     689            sshfos(ji) = zxy * sshsdta(ji,itobcp) + (1.-zxy) * sshsdta(ji,itobcm) 
     690            ubtfos(ji) = zxy * ubtsdta(ji,itobcp) + (1.-zxy) * ubtsdta(ji,itobcm) 
     691            vbtfos(ji) = zxy * vbtsdta(ji,itobcp) + (1.-zxy) * vbtsdta(ji,itobcm) 
     692         END DO 
     693      ENDIF 
     694 
     695   END SUBROUTINE obc_dta_bt 
     696 
     697# else 
     698   !!----------------------------------------------------------------------------- 
     699   !!   Default option 
     700   !!----------------------------------------------------------------------------- 
     701   SUBROUTINE obc_dta_bt ( kt, kbt )       ! Empty routine 
     702      !! * Arguments 
     703      INTEGER,INTENT(in) :: kt 
     704      INTEGER, INTENT( in ) ::   kbt         ! barotropic ocean time-step index 
     705      WRITE(*,*) 'obc_dta_bt: You should not have seen this print! error?', kt 
     706      WRITE(*,*) 'obc_dta_bt: You should not have seen this print! error?', kbt 
     707   END SUBROUTINE obc_dta_bt 
     708# endif 
     709 
     710   SUBROUTINE obc_read (kt, nt_x, ntobc_x, iyy, imm) 
     711      !!------------------------------------------------------------------------- 
     712      !!                      ***  ROUTINE obc_read  *** 
     713      !! 
     714      !! ** Purpose :  Read the boundary data in files identified by iyy and imm 
     715      !!               According to the validated open boundaries, return the  
     716      !!               following arrays : 
     717      !!                sedta, tedta : East OBC salinity and temperature 
     718      !!                uedta, vedta :   "   "  u and v velocity component       
     719      !! 
     720      !!                swdta, twdta : West OBC salinity and temperature 
     721      !!                uwdta, vwdta :   "   "  u and v velocity component       
     722      !! 
     723      !!                sndta, tndta : North OBC salinity and temperature 
     724      !!                undta, vndta :   "   "  u and v velocity component       
     725      !! 
     726      !!                ssdta, tsdta : South OBC salinity and temperature 
     727      !!                usdta, vsdta :   "   "  u and v velocity component       
     728      !! 
     729      !! ** Method  :  These fields are read in the record ntobc_x of the files. 
     730      !!               The number of records is already known. If  ntobc_x is greater 
     731      !!               than the number of record, this routine will look for next file, 
     732      !!               updating the indices (case of inter-annual obcs) or loop at the 
     733      !!               begining in case of climatological file (ln_obc_clim = true ). 
     734      !! ------------------------------------------------------------------------- 
     735      !! History:     !  2005  ( P. Mathiot, C. Langlais ) Original code 
     736      !!              !  2008  ( J,M, Molines ) Use IOM and cleaning 
     737      !!-------------------------------------------------------------------------- 
     738 
     739      ! * Arguments 
     740      INTEGER, INTENT( in ) :: kt, nt_x 
     741      INTEGER, INTENT( inout ) :: ntobc_x , iyy, imm      ! yes ! inout ! 
     742 
     743      ! * Local variables 
     744      CHARACTER (len=40) :: &    ! file names 
    944745         cl_obc_eTS   , cl_obc_eU,  cl_obc_eV,& 
    945746         cl_obc_wTS   , cl_obc_wU,  cl_obc_wV,& 
     
    947748         cl_obc_sTS   , cl_obc_sU,  cl_obc_sV 
    948749 
    949     INTEGER :: ikprint 
    950     REAL(wp) :: zmin, zmax   ! control of boundary values 
    951  
    952     !IOM stuff 
    953     INTEGER :: id_e, id_w, id_n, id_s, ji, jj 
    954     INTEGER, DIMENSION(2) :: istart, icount 
    955     
    956     !-------------------------------------------------------------------------- 
    957     IF ( ntobc_x > itobc ) THEN 
    958       IF (ln_obc_clim) THEN  ! just loop on the same file 
    959         ntobc_x = 1  
    960       ELSE 
    961         ! need to change file : it is always for an 'after' data 
    962         IF ( cffile == 'annual' ) THEN ! go to next year file 
    963           iyy = iyy + 1 
    964         ELSE IF ( cffile =='monthly' ) THEN  ! go to next month file 
    965           imm = imm + 1  
    966           IF ( imm == 13 ) THEN  
    967             imm = 1 ; iyy = iyy + 1 
    968           ENDIF 
    969         ELSE 
    970          ctmp1='obcread : this type of obc file is not supported :( ' 
    971          ctmp2=TRIM(cffile) 
    972          CALL ctl_stop (ctmp1, ctmp2) 
    973          ! cffile should be either annual or monthly ... 
    974         ENDIF 
    975        ! as the file is changed, need to update itobc etc ... 
    976         CALL obc_dta_chktime (iyy,imm) 
    977         ntobc_x = nrecbef() + 1 ! remember : this case occur for an after data 
    978       ENDIF 
    979     ENDIF 
    980  
    981     IF ( lp_obc_east ) THEN  
    982        ! ... Read datafile and set temperature, salinity and normal velocity 
    983        ! ... initialise the sedta, tedta, uedta arrays 
    984        WRITE(cl_obc_eTS ,'("obc_east_TS_y"  ,i4.4,"m",i2.2,".nc")' ) iyy,imm 
    985        WRITE(cl_obc_eU  ,'("obc_east_U_y"   ,i4.4,"m",i2.2,".nc")' ) iyy,imm 
    986        WRITE(cl_obc_eV  ,'("obc_east_V_y"   ,i4.4,"m",i2.2,".nc")' ) iyy,imm 
    987        ! JMM this may change depending on the obc data format ... 
    988        istart(:)=(/nje0+njmpp-1,1/) ; icount(:)=(/nje1-nje0 +1,jpk/) 
    989        IF (lwp) WRITE(numout,*) 'read data in :', TRIM(cl_obc_eTS) 
    990        IF (nje1 >= nje0 ) THEN 
    991           CALL iom_open ( cl_obc_eTS , id_e ) 
    992           CALL iom_get ( id_e, jpdom_unknown, 'votemper', tedta(nje0:nje1,:,nt_x), & 
    993                &               ktime=ntobc_x , kstart=istart, kcount= icount ) 
    994           CALL iom_get ( id_e, jpdom_unknown, 'vosaline', sedta(nje0:nje1,:,nt_x), & 
    995                &               ktime=ntobc_x , kstart=istart, kcount= icount ) 
    996           CALL iom_close (id_e) 
    997           ! 
    998           CALL iom_open ( cl_obc_eU , id_e ) 
    999           CALL iom_get  ( id_e, jpdom_unknown, 'vozocrtx', uedta(nje0:nje1,:,nt_x), & 
    1000                &               ktime=ntobc_x , kstart=istart, kcount= icount ) 
    1001           CALL iom_close ( id_e ) 
    1002           ! 
    1003           CALL iom_open ( cl_obc_eV , id_e ) 
    1004           CALL iom_get ( id_e, jpdom_unknown, 'vomecrty', vedta(nje0:nje1,:,nt_x), & 
    1005                &               ktime=ntobc_x , kstart=istart, kcount= icount ) 
    1006           CALL iom_close ( id_e ) 
    1007  
    1008           ! mask the boundary values 
    1009           tedta(:,:,nt_x) = tedta(:,:,nt_x)*temsk(:,:) ;  sedta(:,:,nt_x) = sedta(:,:,nt_x)*temsk(:,:) 
    1010           uedta(:,:,nt_x) = uedta(:,:,nt_x)*uemsk(:,:) ;  vedta(:,:,nt_x) = vedta(:,:,nt_x)*vemsk(:,:) 
    1011  
    1012           ! check any outliers  
    1013           zmin=MINVAL( sedta(:,:,nt_x), mask=ltemsk ) ; zmax=MAXVAL(sedta(:,:,nt_x), mask=ltemsk) 
    1014           IF (  zmin < 5 .OR. zmax > 50)   THEN 
    1015              CALL ctl_stop('Error in sedta',' routine obcdta') 
    1016           ENDIF 
    1017           zmin=MINVAL( tedta(:,:,nt_x), mask=ltemsk ) ; zmax=MAXVAL(tedta(:,:,nt_x), mask=ltemsk) 
    1018           IF (  zmin < -10. .OR. zmax > 40)   THEN 
    1019              CALL ctl_stop('Error in tedta',' routine obcdta') 
    1020           ENDIF 
    1021           zmin=MINVAL( uedta(:,:,nt_x), mask=luemsk ) ; zmax=MAXVAL(uedta(:,:,nt_x), mask=luemsk) 
    1022           IF (  zmin < -5. .OR. zmax > 5.)   THEN 
    1023              CALL ctl_stop('Error in uedta',' routine obcdta') 
    1024           ENDIF 
    1025           zmin=MINVAL( vedta(:,:,nt_x), mask=lvemsk ) ; zmax=MAXVAL(vedta(:,:,nt_x), mask=lvemsk) 
    1026           IF (  zmin < -5. .OR. zmax > 5.)   THEN 
    1027              CALL ctl_stop('Error in vedta',' routine obcdta') 
    1028           ENDIF 
    1029  
    1030           !               Usually printout is done only once at kt = nit000, unless nprint (namelist) > 1       
    1031           IF ( lwp .AND.  ( kt == nit000 .OR. nprint /= 0 )  ) THEN 
    1032              WRITE(numout,*) 
    1033              WRITE(numout,*) ' Read East OBC data records ', ntobc_x 
    1034              ikprint = jpj/20 +1 
    1035              WRITE(numout,*) ' Temperature  record 1 - printout every 3 level' 
    1036              CALL prihre( tedta(:,:,nt_x), jpj, jpk, 1, jpj, ikprint, jpk, 1, -3, 1., numout ) 
    1037              WRITE(numout,*) 
    1038              WRITE(numout,*) ' Salinity  record 1 - printout every 3 level' 
    1039              CALL prihre( sedta(:,:,nt_x), jpj, jpk, 1, jpj, ikprint, jpk, 1, -3, 1., numout ) 
    1040              WRITE(numout,*) 
    1041              WRITE(numout,*) ' Normal velocity U  record 1  - printout every 3 level' 
    1042              CALL prihre( uedta(:,:,nt_x), jpj, jpk, 1, jpj, ikprint, jpk, 1, -3, 1., numout ) 
    1043              WRITE(numout,*) 
    1044              WRITE(numout,*) ' Tangential velocity V  record 1  - printout every 3 level' 
    1045              CALL prihre( vedta(:,:,nt_x), jpj, jpk, 1, jpj, ikprint, jpk, 1, -3, 1., numout ) 
    1046           ENDIF 
    1047        ENDIF 
    1048     ENDIF 
     750      INTEGER :: ikprint 
     751      REAL(wp) :: zmin, zmax   ! control of boundary values 
     752 
     753      !IOM stuff 
     754      INTEGER :: id_e, id_w, id_n, id_s 
     755      INTEGER, DIMENSION(2) :: istart, icount 
     756 
     757      !-------------------------------------------------------------------------- 
     758      IF ( ntobc_x > itobc ) THEN 
     759         IF (ln_obc_clim) THEN  ! just loop on the same file 
     760            ntobc_x = 1  
     761         ELSE 
     762            ! need to change file : it is always for an 'after' data 
     763            IF ( cffile == 'annual' ) THEN ! go to next year file 
     764               iyy = iyy + 1 
     765            ELSE IF ( cffile =='monthly' ) THEN  ! go to next month file 
     766               imm = imm + 1  
     767               IF ( imm == 13 ) THEN  
     768                  imm = 1 ; iyy = iyy + 1 
     769               ENDIF 
     770            ELSE 
     771               ctmp1='obcread : this type of obc file is not supported :( ' 
     772               ctmp2=TRIM(cffile) 
     773               CALL ctl_stop (ctmp1, ctmp2) 
     774               ! cffile should be either annual or monthly ... 
     775            ENDIF 
     776            ! as the file is changed, need to update itobc etc ... 
     777            CALL obc_dta_chktime (iyy,imm) 
     778            ntobc_x = nrecbef() + 1 ! remember : this case occur for an after data 
     779         ENDIF 
     780      ENDIF 
     781 
     782      IF( lp_obc_east ) THEN  
     783         ! ... Read datafile and set temperature, salinity and normal velocity 
     784         ! ... initialise the sedta, tedta, uedta arrays 
     785         IF(ln_obc_clim) THEN  ! revert to old convention for climatological OBC forcing 
     786            cl_obc_eTS='obceast_TS.nc' 
     787            cl_obc_eU ='obceast_U.nc' 
     788            cl_obc_eV ='obceast_V.nc' 
     789         ELSE                  ! convention for climatological OBC 
     790            WRITE(cl_obc_eTS ,'("obc_east_TS_y"  ,i4.4,"m",i2.2,".nc")' ) iyy,imm 
     791            WRITE(cl_obc_eU  ,'("obc_east_U_y"   ,i4.4,"m",i2.2,".nc")' ) iyy,imm 
     792            WRITE(cl_obc_eV  ,'("obc_east_V_y"   ,i4.4,"m",i2.2,".nc")' ) iyy,imm 
     793         ENDIF 
     794         ! JMM this may change depending on the obc data format ... 
     795         istart(:)=(/nje0+njmpp-1,1/) ; icount(:)=(/nje1-nje0 +1,jpk/) 
     796         IF (lwp) WRITE(numout,*) 'read data in :', TRIM(cl_obc_eTS) 
     797         IF (nje1 >= nje0 ) THEN 
     798            CALL iom_open ( cl_obc_eTS , id_e ) 
     799            CALL iom_get ( id_e, jpdom_unknown, 'votemper', tedta(nje0:nje1,:,nt_x), & 
     800               &               ktime=ntobc_x , kstart=istart, kcount= icount ) 
     801            CALL iom_get ( id_e, jpdom_unknown, 'vosaline', sedta(nje0:nje1,:,nt_x), & 
     802               &               ktime=ntobc_x , kstart=istart, kcount= icount ) 
     803# if defined key_dynspg_ts || defined key_dynspg_exp 
     804            CALL iom_get ( id_e, jpdom_unknown, 'vossurfh', sshedta(nje0:nje1,nt_x), & 
     805               &               ktime=ntobc_x , kstart=istart, kcount= icount ) 
     806# endif 
     807            CALL iom_close (id_e) 
     808            ! 
     809            CALL iom_open ( cl_obc_eU , id_e ) 
     810            CALL iom_get  ( id_e, jpdom_unknown, 'vozocrtx', uedta(nje0:nje1,:,nt_x), & 
     811               &               ktime=ntobc_x , kstart=istart, kcount= icount ) 
     812            CALL iom_close ( id_e ) 
     813            ! 
     814            CALL iom_open ( cl_obc_eV , id_e ) 
     815            CALL iom_get ( id_e, jpdom_unknown, 'vomecrty', vedta(nje0:nje1,:,nt_x), & 
     816               &               ktime=ntobc_x , kstart=istart, kcount= icount ) 
     817            CALL iom_close ( id_e ) 
     818 
     819            ! mask the boundary values 
     820            tedta(:,:,nt_x) = tedta(:,:,nt_x)*temsk(:,:) ;  sedta(:,:,nt_x) = sedta(:,:,nt_x)*temsk(:,:) 
     821            uedta(:,:,nt_x) = uedta(:,:,nt_x)*uemsk(:,:) ;  vedta(:,:,nt_x) = vedta(:,:,nt_x)*vemsk(:,:) 
     822 
     823            ! check any outliers  
     824            zmin=MINVAL( sedta(:,:,nt_x), mask=ltemsk ) ; zmax=MAXVAL(sedta(:,:,nt_x), mask=ltemsk) 
     825            IF (  zmin < 5 .OR. zmax > 50)   THEN 
     826               CALL ctl_stop('Error in sedta',' routine obcdta') 
     827            ENDIF 
     828            zmin=MINVAL( tedta(:,:,nt_x), mask=ltemsk ) ; zmax=MAXVAL(tedta(:,:,nt_x), mask=ltemsk) 
     829            IF (  zmin < -10. .OR. zmax > 40)   THEN 
     830               CALL ctl_stop('Error in tedta',' routine obcdta') 
     831            ENDIF 
     832            zmin=MINVAL( uedta(:,:,nt_x), mask=luemsk ) ; zmax=MAXVAL(uedta(:,:,nt_x), mask=luemsk) 
     833            IF (  zmin < -5. .OR. zmax > 5.)   THEN 
     834               CALL ctl_stop('Error in uedta',' routine obcdta') 
     835            ENDIF 
     836            zmin=MINVAL( vedta(:,:,nt_x), mask=lvemsk ) ; zmax=MAXVAL(vedta(:,:,nt_x), mask=lvemsk) 
     837            IF (  zmin < -5. .OR. zmax > 5.)   THEN 
     838               CALL ctl_stop('Error in vedta',' routine obcdta') 
     839            ENDIF 
     840 
     841            !               Usually printout is done only once at kt = nit000, unless nprint (namelist) > 1       
     842            IF ( lwp .AND.  ( kt == nit000 .OR. nprint /= 0 )  ) THEN 
     843               WRITE(numout,*) 
     844               WRITE(numout,*) ' Read East OBC data records ', ntobc_x 
     845               ikprint = jpj/20 +1 
     846               WRITE(numout,*) ' Temperature  record 1 - printout every 3 level' 
     847               CALL prihre( tedta(:,:,nt_x), jpj, jpk, 1, jpj, ikprint, jpk, 1, -3, 1., numout ) 
     848               WRITE(numout,*) 
     849               WRITE(numout,*) ' Salinity  record 1 - printout every 3 level' 
     850               CALL prihre( sedta(:,:,nt_x), jpj, jpk, 1, jpj, ikprint, jpk, 1, -3, 1., numout ) 
     851               WRITE(numout,*) 
     852               WRITE(numout,*) ' Normal velocity U  record 1  - printout every 3 level' 
     853               CALL prihre( uedta(:,:,nt_x), jpj, jpk, 1, jpj, ikprint, jpk, 1, -3, 1., numout ) 
     854               WRITE(numout,*) 
     855               WRITE(numout,*) ' Tangential velocity V  record 1  - printout every 3 level' 
     856               CALL prihre( vedta(:,:,nt_x), jpj, jpk, 1, jpj, ikprint, jpk, 1, -3, 1., numout ) 
     857            ENDIF 
     858         ENDIF 
     859      ENDIF 
    1049860!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
    1050     IF ( lp_obc_west ) THEN 
    1051        ! ... Read datafile and set temperature, salinity and normal velocity 
    1052        ! ... initialise the swdta, twdta, uwdta arrays 
    1053        WRITE(cl_obc_wTS ,'("obc_west_TS_y"  ,i4.4,"m",i2.2,".nc")' ) iyy,imm 
    1054        WRITE(cl_obc_wU  ,'("obc_west_U_y"   ,i4.4,"m",i2.2,".nc")' ) iyy,imm 
    1055        WRITE(cl_obc_wV  ,'("obc_west_V_y"   ,i4.4,"m",i2.2,".nc")' ) iyy,imm 
    1056        istart(:)=(/njw0+njmpp-1,1/) ; icount(:)=(/njw1-njw0 +1,jpk/) 
    1057        IF (lwp) WRITE(numout,*) 'read data in :', TRIM(cl_obc_wTS) 
    1058  
    1059        IF ( njw1 >= njw0 ) THEN 
    1060           CALL iom_open ( cl_obc_wTS , id_w ) 
    1061           CALL iom_get ( id_w, jpdom_unknown, 'votemper', twdta(njw0:njw1,:,nt_x), &  
    1062                &               ktime=ntobc_x , kstart=istart, kcount= icount ) 
    1063  
    1064           CALL iom_get ( id_w, jpdom_unknown, 'vosaline', swdta(njw0:njw1,:,nt_x), & 
     861      IF ( lp_obc_west ) THEN 
     862         ! ... Read datafile and set temperature, salinity and normal velocity 
     863         ! ... initialise the swdta, twdta, uwdta arrays 
     864         IF (ln_obc_clim) THEN   ! revert to old convention for climatological OBC forcing 
     865            cl_obc_wTS='obcwest_TS.nc' 
     866            cl_obc_wU ='obcwest_U.nc' 
     867            cl_obc_wV ='obcwest_V.nc' 
     868         ELSE                    ! convention for climatological OBC 
     869            WRITE(cl_obc_wTS ,'("obc_west_TS_y"  ,i4.4,"m",i2.2,".nc")' ) iyy,imm 
     870            WRITE(cl_obc_wU  ,'("obc_west_U_y"   ,i4.4,"m",i2.2,".nc")' ) iyy,imm 
     871            WRITE(cl_obc_wV  ,'("obc_west_V_y"   ,i4.4,"m",i2.2,".nc")' ) iyy,imm 
     872         ENDIF 
     873         istart(:)=(/njw0+njmpp-1,1/) ; icount(:)=(/njw1-njw0 +1,jpk/) 
     874         IF (lwp) WRITE(numout,*) 'read data in :', TRIM(cl_obc_wTS) 
     875 
     876         IF ( njw1 >= njw0 ) THEN 
     877            CALL iom_open ( cl_obc_wTS , id_w ) 
     878            CALL iom_get ( id_w, jpdom_unknown, 'votemper', twdta(njw0:njw1,:,nt_x), &  
     879               &               ktime=ntobc_x , kstart=istart, kcount= icount ) 
     880 
     881            CALL iom_get ( id_w, jpdom_unknown, 'vosaline', swdta(njw0:njw1,:,nt_x), & 
    1065882               &               ktime=ntobc_x , kstart=istart, kcount= icount) 
    1066           CALL iom_close (id_w) 
    1067           ! 
    1068           CALL iom_open ( cl_obc_wU , id_w ) 
    1069           CALL iom_get  ( id_w, jpdom_unknown, 'vozocrtx', uwdta(njw0:njw1,:,nt_x),& 
    1070                &               ktime=ntobc_x , kstart=istart, kcount= icount ) 
    1071           CALL iom_close ( id_w ) 
    1072           ! 
    1073           CALL iom_open ( cl_obc_wV , id_w ) 
    1074           CALL iom_get ( id_w, jpdom_unknown, 'vomecrty', vwdta(njw0:njw1,:,nt_x), & 
    1075                &               ktime=ntobc_x , kstart=istart, kcount= icount ) 
    1076           CALL iom_close ( id_w ) 
    1077  
    1078           ! mask the boundary values 
    1079           twdta(:,:,nt_x) = twdta(:,:,nt_x)*twmsk(:,:) ;  swdta(:,:,nt_x) = swdta(:,:,nt_x)*twmsk(:,:) 
    1080           uwdta(:,:,nt_x) = uwdta(:,:,nt_x)*uwmsk(:,:) ;  vwdta(:,:,nt_x) = vwdta(:,:,nt_x)*vwmsk(:,:) 
    1081  
    1082           ! check any outliers 
    1083           zmin=MINVAL( swdta(:,:,nt_x), mask=ltwmsk ) ; zmax=MAXVAL(swdta(:,:,nt_x), mask=ltwmsk) 
    1084           IF (  zmin < 5 .OR. zmax > 50)   THEN 
    1085              CALL ctl_stop('Error in swdta',' routine obcdta') 
    1086           ENDIF 
    1087           zmin=MINVAL( twdta(:,:,nt_x), mask=ltwmsk ) ; zmax=MAXVAL(twdta(:,:,nt_x), mask=ltwmsk) 
    1088           IF (  zmin < -10. .OR. zmax > 40)   THEN 
    1089              CALL ctl_stop('Error in twdta',' routine obcdta') 
    1090           ENDIF 
    1091           zmin=MINVAL( uwdta(:,:,nt_x), mask=luwmsk ) ; zmax=MAXVAL(uwdta(:,:,nt_x), mask=luwmsk) 
    1092           IF (  zmin < -5. .OR. zmax > 5.)   THEN 
    1093              CALL ctl_stop('Error in uwdta',' routine obcdta') 
    1094           ENDIF 
    1095           zmin=MINVAL( vwdta(:,:,nt_x), mask=lvwmsk ) ; zmax=MAXVAL(vwdta(:,:,nt_x), mask=lvwmsk) 
    1096           IF (  zmin < -5. .OR. zmax > 5.)   THEN 
    1097              CALL ctl_stop('Error in vwdta',' routine obcdta') 
    1098           ENDIF 
    1099  
    1100  
    1101           IF ( lwp .AND.  ( kt == nit000 .OR. nprint /= 0 )  ) THEN 
    1102              WRITE(numout,*) 
    1103              WRITE(numout,*) ' Read West OBC data records ', ntobc_x 
    1104              ikprint = jpj/20 +1 
    1105              WRITE(numout,*) ' Temperature  record 1 - printout every 3 level' 
    1106              CALL prihre( twdta(:,:,nt_x), jpj, jpk, 1, jpj, ikprint, jpk, 1, -3, 1., numout ) 
    1107              WRITE(numout,*) 
    1108              WRITE(numout,*) ' Salinity  record 1 - printout every 3 level' 
    1109              CALL prihre( swdta(:,:,nt_x),jpj,jpk, 1, jpj, ikprint,   jpk, 1, -3, 1., numout ) 
    1110              WRITE(numout,*) 
    1111              WRITE(numout,*) ' Normal velocity U  record 1  - printout every 3 level' 
    1112              CALL prihre( uwdta(:,:,nt_x), jpj, jpk, 1, jpj, ikprint, jpk, 1, -3, 1., numout ) 
    1113              WRITE(numout,*) 
    1114              WRITE(numout,*) ' Tangential velocity V  record 1  - printout every 3 level' 
    1115              CALL prihre( vwdta(:,:,nt_x), jpj, jpk, 1, jpj, ikprint, jpk, 1, -3, 1., numout ) 
    1116           ENDIF 
    1117        END IF 
    1118     ENDIF 
     883# if defined key_dynspg_ts || defined key_dynspg_exp 
     884            CALL iom_get ( id_w, jpdom_unknown, 'vossurfh', sshwdta(njw0:njw1,nt_x), & 
     885               &               ktime=ntobc_x , kstart=istart, kcount= icount ) 
     886# endif 
     887            CALL iom_close (id_w) 
     888            ! 
     889            CALL iom_open ( cl_obc_wU , id_w ) 
     890            CALL iom_get  ( id_w, jpdom_unknown, 'vozocrtx', uwdta(njw0:njw1,:,nt_x),& 
     891               &               ktime=ntobc_x , kstart=istart, kcount= icount ) 
     892            CALL iom_close ( id_w ) 
     893            ! 
     894            CALL iom_open ( cl_obc_wV , id_w ) 
     895            CALL iom_get ( id_w, jpdom_unknown, 'vomecrty', vwdta(njw0:njw1,:,nt_x), & 
     896               &               ktime=ntobc_x , kstart=istart, kcount= icount ) 
     897            CALL iom_close ( id_w ) 
     898 
     899            ! mask the boundary values 
     900            twdta(:,:,nt_x) = twdta(:,:,nt_x)*twmsk(:,:) ;  swdta(:,:,nt_x) = swdta(:,:,nt_x)*twmsk(:,:) 
     901            uwdta(:,:,nt_x) = uwdta(:,:,nt_x)*uwmsk(:,:) ;  vwdta(:,:,nt_x) = vwdta(:,:,nt_x)*vwmsk(:,:) 
     902 
     903            ! check any outliers 
     904            zmin=MINVAL( swdta(:,:,nt_x), mask=ltwmsk ) ; zmax=MAXVAL(swdta(:,:,nt_x), mask=ltwmsk) 
     905            IF (  zmin < 5 .OR. zmax > 50)   THEN 
     906               CALL ctl_stop('Error in swdta',' routine obcdta') 
     907            ENDIF 
     908            zmin=MINVAL( twdta(:,:,nt_x), mask=ltwmsk ) ; zmax=MAXVAL(twdta(:,:,nt_x), mask=ltwmsk) 
     909            IF (  zmin < -10. .OR. zmax > 40)   THEN 
     910               CALL ctl_stop('Error in twdta',' routine obcdta') 
     911            ENDIF 
     912            zmin=MINVAL( uwdta(:,:,nt_x), mask=luwmsk ) ; zmax=MAXVAL(uwdta(:,:,nt_x), mask=luwmsk) 
     913            IF (  zmin < -5. .OR. zmax > 5.)   THEN 
     914               CALL ctl_stop('Error in uwdta',' routine obcdta') 
     915            ENDIF 
     916            zmin=MINVAL( vwdta(:,:,nt_x), mask=lvwmsk ) ; zmax=MAXVAL(vwdta(:,:,nt_x), mask=lvwmsk) 
     917            IF (  zmin < -5. .OR. zmax > 5.)   THEN 
     918               CALL ctl_stop('Error in vwdta',' routine obcdta') 
     919            ENDIF 
     920 
     921 
     922            IF ( lwp .AND.  ( kt == nit000 .OR. nprint /= 0 )  ) THEN 
     923               WRITE(numout,*) 
     924               WRITE(numout,*) ' Read West OBC data records ', ntobc_x 
     925               ikprint = jpj/20 +1 
     926               WRITE(numout,*) ' Temperature  record 1 - printout every 3 level' 
     927               CALL prihre( twdta(:,:,nt_x), jpj, jpk, 1, jpj, ikprint, jpk, 1, -3, 1., numout ) 
     928               WRITE(numout,*) 
     929               WRITE(numout,*) ' Salinity  record 1 - printout every 3 level' 
     930               CALL prihre( swdta(:,:,nt_x),jpj,jpk, 1, jpj, ikprint,   jpk, 1, -3, 1., numout ) 
     931               WRITE(numout,*) 
     932               WRITE(numout,*) ' Normal velocity U  record 1  - printout every 3 level' 
     933               CALL prihre( uwdta(:,:,nt_x), jpj, jpk, 1, jpj, ikprint, jpk, 1, -3, 1., numout ) 
     934               WRITE(numout,*) 
     935               WRITE(numout,*) ' Tangential velocity V  record 1  - printout every 3 level' 
     936               CALL prihre( vwdta(:,:,nt_x), jpj, jpk, 1, jpj, ikprint, jpk, 1, -3, 1., numout ) 
     937            ENDIF 
     938         END IF 
     939      ENDIF 
    1119940!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
    1120     IF( lp_obc_north) THEN 
    1121        WRITE(cl_obc_nTS ,'("obc_north_TS_y" ,i4.4,"m",i2.2,".nc")' ) iyy,imm 
    1122        WRITE(cl_obc_nV  ,'("obc_north_V_y"  ,i4.4,"m",i2.2,".nc")' ) iyy,imm 
    1123        WRITE(cl_obc_nU  ,'("obc_north_U_y"  ,i4.4,"m",i2.2,".nc")' ) iyy,imm 
    1124        istart(:)=(/nin0+nimpp-1,1/) ; icount(:)=(/nin1-nin0 +1,jpk/) 
    1125        IF (lwp) WRITE(numout,*) 'read data in :', TRIM(cl_obc_nTS) 
    1126        IF ( nin1 >= nin0 ) THEN 
    1127           CALL iom_open ( cl_obc_nTS , id_n ) 
    1128           CALL iom_get ( id_n, jpdom_unknown, 'votemper', tndta(nin0:nin1,:,nt_x), & 
    1129                &               ktime=ntobc_x , kstart=istart, kcount= icount ) 
    1130           CALL iom_get ( id_n, jpdom_unknown, 'vosaline', sndta(nin0:nin1,:,nt_x), & 
    1131                &               ktime=ntobc_x , kstart=istart, kcount= icount ) 
    1132           CALL iom_close (id_n) 
    1133           ! 
    1134           CALL iom_open ( cl_obc_nU , id_n ) 
    1135           CALL iom_get  ( id_n, jpdom_unknown, 'vozocrtx', undta(nin0:nin1,:,nt_x), & 
    1136                &               ktime=ntobc_x , kstart=istart, kcount= icount ) 
    1137           CALL iom_close ( id_n ) 
    1138           ! 
    1139           CALL iom_open ( cl_obc_nV , id_n ) 
    1140           CALL iom_get  ( id_n, jpdom_unknown, 'vomecrty', vndta(nin0:nin1,:,nt_x), & 
    1141                &               ktime=ntobc_x , kstart=istart, kcount= icount ) 
    1142           CALL iom_close ( id_n ) 
    1143  
    1144           ! mask the boundary values 
    1145           tndta(:,:,nt_x) = tndta(:,:,nt_x)*tnmsk(:,:) ;  sndta(:,:,nt_x) = sndta(:,:,nt_x)*tnmsk(:,:) 
    1146           undta(:,:,nt_x) = undta(:,:,nt_x)*unmsk(:,:) ;  vndta(:,:,nt_x) = vndta(:,:,nt_x)*vnmsk(:,:) 
    1147  
    1148           ! check any outliers 
    1149           zmin=MINVAL( sndta(:,:,nt_x), mask=ltnmsk ) ; zmax=MAXVAL(sndta(:,:,nt_x), mask=ltnmsk) 
    1150           IF (  zmin < 5 .OR. zmax > 50)   THEN 
    1151              CALL ctl_stop('Error in sndta',' routine obcdta') 
    1152           ENDIF 
    1153           zmin=MINVAL( tndta(:,:,nt_x), mask=ltnmsk ) ; zmax=MAXVAL(tndta(:,:,nt_x), mask=ltnmsk) 
    1154           IF (  zmin < -10. .OR. zmax > 40)   THEN 
    1155              CALL ctl_stop('Error in tndta',' routine obcdta') 
    1156           ENDIF 
    1157           zmin=MINVAL( undta(:,:,nt_x), mask=lunmsk ) ; zmax=MAXVAL(undta(:,:,nt_x), mask=lunmsk) 
    1158           IF (  zmin < -5. .OR. zmax > 5.)   THEN 
    1159              CALL ctl_stop('Error in undta',' routine obcdta') 
    1160           ENDIF 
    1161           zmin=MINVAL( vndta(:,:,nt_x), mask=lvnmsk ) ; zmax=MAXVAL(vndta(:,:,nt_x), mask=lvnmsk) 
    1162           IF (  zmin < -5. .OR. zmax > 5.)   THEN 
    1163              CALL ctl_stop('Error in vndta',' routine obcdta') 
    1164           ENDIF 
    1165  
    1166           IF ( lwp .AND.  ( kt == nit000 .OR. nprint /= 0 )  ) THEN 
    1167              WRITE(numout,*) 
    1168              WRITE(numout,*) ' Read North OBC data records ', ntobc_x 
    1169              ikprint = jpi/20 +1 
    1170              WRITE(numout,*) ' Temperature  record 1 - printout every 3 level' 
    1171              CALL prihre( tndta(:,:,nt_x), jpi, jpk, 1, jpi, ikprint, jpk, 1, -3, 1., numout ) 
    1172              WRITE(numout,*) 
    1173              WRITE(numout,*) ' Salinity  record 1 - printout every 3 level' 
    1174              CALL prihre( sndta(:,:,nt_x), jpi, jpk, 1, jpi, ikprint, jpk, 1, -3, 1., numout ) 
    1175              WRITE(numout,*) 
    1176              WRITE(numout,*) ' Normal velocity V  record 1  - printout every 3 level' 
    1177              CALL prihre( vndta(:,:,nt_x), jpi, jpk, 1, jpi, ikprint, jpk, 1, -3, 1., numout ) 
    1178              WRITE(numout,*) 
    1179              WRITE(numout,*) ' Tangential  velocity U  record 1  - printout every 3 level' 
    1180              CALL prihre( undta(:,:,nt_x), jpi, jpk, 1, jpi, ikprint, jpk, 1, -3, 1., numout ) 
    1181           ENDIF 
    1182        ENDIF 
    1183     ENDIF 
     941      IF( lp_obc_north) THEN 
     942         IF(ln_obc_clim) THEN   ! revert to old convention for climatological OBC forcing 
     943            cl_obc_nTS='obcnorth_TS.nc' 
     944            cl_obc_nU ='obcnorth_U.nc' 
     945            cl_obc_nV ='obcnorth_V.nc' 
     946         ELSE                   ! convention for climatological OBC 
     947            WRITE(cl_obc_nTS ,'("obc_north_TS_y" ,i4.4,"m",i2.2,".nc")' ) iyy,imm 
     948            WRITE(cl_obc_nV  ,'("obc_north_V_y"  ,i4.4,"m",i2.2,".nc")' ) iyy,imm 
     949            WRITE(cl_obc_nU  ,'("obc_north_U_y"  ,i4.4,"m",i2.2,".nc")' ) iyy,imm 
     950         ENDIF 
     951         istart(:)=(/nin0+nimpp-1,1/) ; icount(:)=(/nin1-nin0 +1,jpk/) 
     952         IF (lwp) WRITE(numout,*) 'read data in :', TRIM(cl_obc_nTS) 
     953         IF ( nin1 >= nin0 ) THEN 
     954            CALL iom_open ( cl_obc_nTS , id_n ) 
     955            CALL iom_get ( id_n, jpdom_unknown, 'votemper', tndta(nin0:nin1,:,nt_x), & 
     956               &               ktime=ntobc_x , kstart=istart, kcount= icount ) 
     957            CALL iom_get ( id_n, jpdom_unknown, 'vosaline', sndta(nin0:nin1,:,nt_x), & 
     958               &               ktime=ntobc_x , kstart=istart, kcount= icount ) 
     959# if defined key_dynspg_ts || defined key_dynspg_exp 
     960            CALL iom_get ( id_n, jpdom_unknown, 'vossurfh', sshndta(nin0:nin1,nt_x), & 
     961               &               ktime=ntobc_x , kstart=istart, kcount= icount ) 
     962# endif 
     963            CALL iom_close (id_n) 
     964            ! 
     965            CALL iom_open ( cl_obc_nU , id_n ) 
     966            CALL iom_get  ( id_n, jpdom_unknown, 'vozocrtx', undta(nin0:nin1,:,nt_x), & 
     967               &               ktime=ntobc_x , kstart=istart, kcount= icount ) 
     968            CALL iom_close ( id_n ) 
     969            ! 
     970            CALL iom_open ( cl_obc_nV , id_n ) 
     971            CALL iom_get  ( id_n, jpdom_unknown, 'vomecrty', vndta(nin0:nin1,:,nt_x), & 
     972               &               ktime=ntobc_x , kstart=istart, kcount= icount ) 
     973            CALL iom_close ( id_n ) 
     974 
     975            ! mask the boundary values 
     976            tndta(:,:,nt_x) = tndta(:,:,nt_x)*tnmsk(:,:) ;  sndta(:,:,nt_x) = sndta(:,:,nt_x)*tnmsk(:,:) 
     977            undta(:,:,nt_x) = undta(:,:,nt_x)*unmsk(:,:) ;  vndta(:,:,nt_x) = vndta(:,:,nt_x)*vnmsk(:,:) 
     978 
     979            ! check any outliers 
     980            zmin=MINVAL( sndta(:,:,nt_x), mask=ltnmsk ) ; zmax=MAXVAL(sndta(:,:,nt_x), mask=ltnmsk) 
     981            IF (  zmin < 5 .OR. zmax > 50)   THEN 
     982               CALL ctl_stop('Error in sndta',' routine obcdta') 
     983            ENDIF 
     984            zmin=MINVAL( tndta(:,:,nt_x), mask=ltnmsk ) ; zmax=MAXVAL(tndta(:,:,nt_x), mask=ltnmsk) 
     985            IF (  zmin < -10. .OR. zmax > 40)   THEN 
     986               CALL ctl_stop('Error in tndta',' routine obcdta') 
     987            ENDIF 
     988            zmin=MINVAL( undta(:,:,nt_x), mask=lunmsk ) ; zmax=MAXVAL(undta(:,:,nt_x), mask=lunmsk) 
     989            IF (  zmin < -5. .OR. zmax > 5.)   THEN 
     990               CALL ctl_stop('Error in undta',' routine obcdta') 
     991            ENDIF 
     992            zmin=MINVAL( vndta(:,:,nt_x), mask=lvnmsk ) ; zmax=MAXVAL(vndta(:,:,nt_x), mask=lvnmsk) 
     993            IF (  zmin < -5. .OR. zmax > 5.)   THEN 
     994               CALL ctl_stop('Error in vndta',' routine obcdta') 
     995            ENDIF 
     996 
     997            IF ( lwp .AND.  ( kt == nit000 .OR. nprint /= 0 )  ) THEN 
     998               WRITE(numout,*) 
     999               WRITE(numout,*) ' Read North OBC data records ', ntobc_x 
     1000               ikprint = jpi/20 +1 
     1001               WRITE(numout,*) ' Temperature  record 1 - printout every 3 level' 
     1002               CALL prihre( tndta(:,:,nt_x), jpi, jpk, 1, jpi, ikprint, jpk, 1, -3, 1., numout ) 
     1003               WRITE(numout,*) 
     1004               WRITE(numout,*) ' Salinity  record 1 - printout every 3 level' 
     1005               CALL prihre( sndta(:,:,nt_x), jpi, jpk, 1, jpi, ikprint, jpk, 1, -3, 1., numout ) 
     1006               WRITE(numout,*) 
     1007               WRITE(numout,*) ' Normal velocity V  record 1  - printout every 3 level' 
     1008               CALL prihre( vndta(:,:,nt_x), jpi, jpk, 1, jpi, ikprint, jpk, 1, -3, 1., numout ) 
     1009               WRITE(numout,*) 
     1010               WRITE(numout,*) ' Tangential  velocity U  record 1  - printout every 3 level' 
     1011               CALL prihre( undta(:,:,nt_x), jpi, jpk, 1, jpi, ikprint, jpk, 1, -3, 1., numout ) 
     1012            ENDIF 
     1013         ENDIF 
     1014      ENDIF 
    11841015!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
    1185     IF( lp_obc_south) THEN  
    1186        WRITE(cl_obc_sTS ,'("obc_south_TS_y" ,i4.4,"m",i2.2,".nc")' ) iyy,imm 
    1187        WRITE(cl_obc_sV  ,'("obc_south_V_y"  ,i4.4,"m",i2.2,".nc")' ) iyy,imm 
    1188        WRITE(cl_obc_sU  ,'("obc_south_U_y"  ,i4.4,"m",i2.2,".nc")' ) iyy,imm 
    1189        istart(:)=(/nis0+nimpp-1,1/) ; icount(:)=(/nis1-nis0 +1,jpk/) 
    1190        IF (lwp) WRITE(numout,*) 'read data in :', TRIM(cl_obc_sTS) 
    1191        IF ( nis1 >= nis0 ) THEN  
    1192           CALL iom_open ( cl_obc_sTS , id_s ) 
    1193           CALL iom_get ( id_s, jpdom_unknown, 'votemper', tsdta(nis0:nis1,:,nt_x), & 
    1194                &               ktime=ntobc_x , kstart=istart, kcount= icount ) 
    1195           CALL iom_get ( id_s, jpdom_unknown, 'vosaline', ssdta(nis0:nis1,:,nt_x), & 
    1196                &               ktime=ntobc_x , kstart=istart, kcount= icount ) 
    1197           CALL iom_close (id_s) 
    1198           ! 
    1199           CALL iom_open ( cl_obc_sU , id_s ) 
    1200           CALL iom_get  ( id_s, jpdom_unknown, 'vozocrtx', usdta(nis0:nis1,:,nt_x), & 
    1201                &               ktime=ntobc_x , kstart=istart, kcount= icount ) 
    1202           CALL iom_close ( id_s ) 
    1203           ! 
    1204           CALL iom_open ( cl_obc_sV , id_s ) 
    1205           CALL iom_get  ( id_s, jpdom_unknown, 'vomecrty', vsdta(nis0:nis1,:,nt_x), & 
    1206                &               ktime=ntobc_x , kstart=istart, kcount= icount ) 
    1207           CALL iom_close ( id_s ) 
    1208  
    1209           ! mask the boundary values 
    1210           tsdta(:,:,nt_x) = tsdta(:,:,nt_x)*tsmsk(:,:) ;  ssdta(:,:,nt_x) = ssdta(:,:,nt_x)*tsmsk(:,:) 
    1211           usdta(:,:,nt_x) = usdta(:,:,nt_x)*usmsk(:,:) ;  vsdta(:,:,nt_x) = vsdta(:,:,nt_x)*vsmsk(:,:) 
    1212  
    1213           ! check any outliers 
    1214           zmin=MINVAL( ssdta(:,:,nt_x), mask=ltsmsk ) ; zmax=MAXVAL(ssdta(:,:,nt_x), mask=ltsmsk) 
    1215           IF (  zmin < 5 .OR. zmax > 50)   THEN 
    1216              CALL ctl_stop('Error in ssdta',' routine obcdta') 
    1217           ENDIF 
    1218           zmin=MINVAL( tsdta(:,:,nt_x), mask=ltsmsk ) ; zmax=MAXVAL(tsdta(:,:,nt_x), mask=ltsmsk) 
    1219           IF (  zmin < -10. .OR. zmax > 40)   THEN 
    1220              CALL ctl_stop('Error in tsdta',' routine obcdta') 
    1221           ENDIF 
    1222           zmin=MINVAL( usdta(:,:,nt_x), mask=lusmsk ) ; zmax=MAXVAL(usdta(:,:,nt_x), mask=lusmsk) 
    1223           IF (  zmin < -5. .OR. zmax > 5.)   THEN 
    1224              CALL ctl_stop('Error in usdta',' routine obcdta') 
    1225           ENDIF 
    1226           zmin=MINVAL( vsdta(:,:,nt_x), mask=lvsmsk ) ; zmax=MAXVAL(vsdta(:,:,nt_x), mask=lvsmsk) 
    1227           IF (  zmin < -5. .OR. zmax > 5.)   THEN 
    1228              CALL ctl_stop('Error in vsdta',' routine obcdta') 
    1229           ENDIF 
    1230  
    1231           IF ( lwp .AND.  ( kt == nit000 .OR. nprint /= 0 )  ) THEN 
    1232              WRITE(numout,*) 
    1233              WRITE(numout,*) ' Read South OBC data records ', ntobc_x 
    1234              ikprint = jpi/20 +1 
    1235              WRITE(numout,*) ' Temperature  record 1 - printout every 3 level' 
    1236              CALL prihre( tsdta(:,:,nt_x), jpi, jpk, 1, jpi, ikprint, jpk, 1, -3, 1., numout ) 
    1237              WRITE(numout,*) 
    1238              WRITE(numout,*) ' Salinity  record 1 - printout every 3 level' 
    1239              CALL prihre( ssdta(:,:,nt_x), jpi, jpk, 1, jpi, ikprint, jpk, 1, -3, 1., numout ) 
    1240              WRITE(numout,*) 
    1241              WRITE(numout,*) ' Normal velocity V  record 1  - printout every 3 level' 
    1242              CALL prihre( vsdta(:,:,nt_x), jpi, jpk, 1, jpi, ikprint, jpk, 1, -3, 1., numout ) 
    1243              WRITE(numout,*) 
    1244              WRITE(numout,*) ' Tangential velocity U  record 1  - printout every 3 level' 
    1245              CALL prihre( usdta(:,:,nt_x), jpi, jpk, 1, jpi, ikprint, jpk, 1, -3, 1., numout ) 
    1246           ENDIF 
    1247        ENDIF 
    1248     ENDIF 
     1016      IF( lp_obc_south) THEN  
     1017         IF(ln_obc_clim) THEN   ! revert to old convention for climatological OBC forcing 
     1018            cl_obc_sTS='obcsouth_TS.nc' 
     1019            cl_obc_sU ='obcsouth_U.nc' 
     1020            cl_obc_sV ='obcsouth_V.nc' 
     1021         ELSE                    ! convention for climatological OBC 
     1022            WRITE(cl_obc_sTS ,'("obc_south_TS_y" ,i4.4,"m",i2.2,".nc")' ) iyy,imm 
     1023            WRITE(cl_obc_sV  ,'("obc_south_V_y"  ,i4.4,"m",i2.2,".nc")' ) iyy,imm 
     1024            WRITE(cl_obc_sU  ,'("obc_south_U_y"  ,i4.4,"m",i2.2,".nc")' ) iyy,imm 
     1025         ENDIF 
     1026         istart(:)=(/nis0+nimpp-1,1/) ; icount(:)=(/nis1-nis0 +1,jpk/) 
     1027         IF (lwp) WRITE(numout,*) 'read data in :', TRIM(cl_obc_sTS) 
     1028         IF ( nis1 >= nis0 ) THEN  
     1029            CALL iom_open ( cl_obc_sTS , id_s ) 
     1030            CALL iom_get ( id_s, jpdom_unknown, 'votemper', tsdta(nis0:nis1,:,nt_x), & 
     1031               &               ktime=ntobc_x , kstart=istart, kcount= icount ) 
     1032            CALL iom_get ( id_s, jpdom_unknown, 'vosaline', ssdta(nis0:nis1,:,nt_x), & 
     1033               &               ktime=ntobc_x , kstart=istart, kcount= icount ) 
     1034# if defined key_dynspg_ts || defined key_dynspg_exp 
     1035            CALL iom_get ( id_s, jpdom_unknown, 'vossurfh', sshsdta(nis0:nis1,nt_x), & 
     1036               &               ktime=ntobc_x , kstart=istart, kcount= icount ) 
     1037# endif 
     1038            CALL iom_close (id_s) 
     1039            ! 
     1040            CALL iom_open ( cl_obc_sU , id_s ) 
     1041            CALL iom_get  ( id_s, jpdom_unknown, 'vozocrtx', usdta(nis0:nis1,:,nt_x), & 
     1042               &               ktime=ntobc_x , kstart=istart, kcount= icount ) 
     1043            CALL iom_close ( id_s ) 
     1044            ! 
     1045            CALL iom_open ( cl_obc_sV , id_s ) 
     1046            CALL iom_get  ( id_s, jpdom_unknown, 'vomecrty', vsdta(nis0:nis1,:,nt_x), & 
     1047               &               ktime=ntobc_x , kstart=istart, kcount= icount ) 
     1048            CALL iom_close ( id_s ) 
     1049 
     1050            ! mask the boundary values 
     1051            tsdta(:,:,nt_x) = tsdta(:,:,nt_x)*tsmsk(:,:) ;  ssdta(:,:,nt_x) = ssdta(:,:,nt_x)*tsmsk(:,:) 
     1052            usdta(:,:,nt_x) = usdta(:,:,nt_x)*usmsk(:,:) ;  vsdta(:,:,nt_x) = vsdta(:,:,nt_x)*vsmsk(:,:) 
     1053 
     1054            ! check any outliers 
     1055            zmin=MINVAL( ssdta(:,:,nt_x), mask=ltsmsk ) ; zmax=MAXVAL(ssdta(:,:,nt_x), mask=ltsmsk) 
     1056            IF (  zmin < 5 .OR. zmax > 50)   THEN 
     1057               CALL ctl_stop('Error in ssdta',' routine obcdta') 
     1058            ENDIF 
     1059            zmin=MINVAL( tsdta(:,:,nt_x), mask=ltsmsk ) ; zmax=MAXVAL(tsdta(:,:,nt_x), mask=ltsmsk) 
     1060            IF (  zmin < -10. .OR. zmax > 40)   THEN 
     1061               CALL ctl_stop('Error in tsdta',' routine obcdta') 
     1062            ENDIF 
     1063            zmin=MINVAL( usdta(:,:,nt_x), mask=lusmsk ) ; zmax=MAXVAL(usdta(:,:,nt_x), mask=lusmsk) 
     1064            IF (  zmin < -5. .OR. zmax > 5.)   THEN 
     1065               CALL ctl_stop('Error in usdta',' routine obcdta') 
     1066            ENDIF 
     1067            zmin=MINVAL( vsdta(:,:,nt_x), mask=lvsmsk ) ; zmax=MAXVAL(vsdta(:,:,nt_x), mask=lvsmsk) 
     1068            IF (  zmin < -5. .OR. zmax > 5.)   THEN 
     1069               CALL ctl_stop('Error in vsdta',' routine obcdta') 
     1070            ENDIF 
     1071 
     1072            IF ( lwp .AND.  ( kt == nit000 .OR. nprint /= 0 )  ) THEN 
     1073               WRITE(numout,*) 
     1074               WRITE(numout,*) ' Read South OBC data records ', ntobc_x 
     1075               ikprint = jpi/20 +1 
     1076               WRITE(numout,*) ' Temperature  record 1 - printout every 3 level' 
     1077               CALL prihre( tsdta(:,:,nt_x), jpi, jpk, 1, jpi, ikprint, jpk, 1, -3, 1., numout ) 
     1078               WRITE(numout,*) 
     1079               WRITE(numout,*) ' Salinity  record 1 - printout every 3 level' 
     1080               CALL prihre( ssdta(:,:,nt_x), jpi, jpk, 1, jpi, ikprint, jpk, 1, -3, 1., numout ) 
     1081               WRITE(numout,*) 
     1082               WRITE(numout,*) ' Normal velocity V  record 1  - printout every 3 level' 
     1083               CALL prihre( vsdta(:,:,nt_x), jpi, jpk, 1, jpi, ikprint, jpk, 1, -3, 1., numout ) 
     1084               WRITE(numout,*) 
     1085               WRITE(numout,*) ' Tangential velocity U  record 1  - printout every 3 level' 
     1086               CALL prihre( usdta(:,:,nt_x), jpi, jpk, 1, jpi, ikprint, jpk, 1, -3, 1., numout ) 
     1087            ENDIF 
     1088         ENDIF 
     1089      ENDIF 
     1090 
     1091# if defined key_dynspg_ts || defined key_dynspg_exp 
     1092      CALL obc_depth_average(nt_x)   ! computation of depth-averaged velocity 
     1093# endif 
     1094 
    12491095!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! 
    1250   END SUBROUTINE obc_read  
    1251  
    1252   INTEGER FUNCTION nrecbef() 
     1096   END SUBROUTINE obc_read 
     1097 
     1098   INTEGER FUNCTION nrecbef() 
    12531099      !!----------------------------------------------------------------------- 
    12541100      !!                     ***    FUNCTION nrecbef   *** 
     
    12611107      INTEGER :: it , idum 
    12621108 
    1263     idum = itobc 
    1264     DO it =1, itobc 
    1265        IF ( ztcobc(it) > zjcnes ) THEN ;  idum = it - 1 ; EXIT ;  ENDIF 
    1266     ENDDO 
    1267     ! idum can be 0 (climato, before first record) 
    1268     IF ( idum == 0 ) THEN 
    1269        IF ( ln_obc_clim ) THEN 
    1270          idum = itobc 
    1271        ELSE 
    1272          ctmp1='obc_dta: find ntobc == 0 for  non climatological file ' 
    1273          ctmp2='consider adding a first record in your data file ' 
    1274          CALL ctl_stop(ctmp1, ctmp2) 
    1275        ENDIF 
    1276     ENDIF 
    1277     ! idum can be itobc ( zjcnes > ztcobc (itobc) ) 
    1278     !  This is not a problem ... 
    1279     nrecbef = idum 
    1280  
    1281   END FUNCTION nrecbef 
     1109      idum = itobc 
     1110      DO it =1, itobc 
     1111         IF ( ztcobc(it) > zjcnes ) THEN ;  idum = it - 1 ; EXIT ;  ENDIF 
     1112         ENDDO 
     1113         ! idum can be 0 (climato, before first record) 
     1114         IF ( idum == 0 ) THEN 
     1115            IF ( ln_obc_clim ) THEN 
     1116               idum = itobc 
     1117            ELSE 
     1118               ctmp1='obc_dta: find ntobc == 0 for  non climatological file ' 
     1119               ctmp2='consider adding a first record in your data file ' 
     1120               CALL ctl_stop(ctmp1, ctmp2) 
     1121            ENDIF 
     1122         ENDIF 
     1123         ! idum can be itobc ( zjcnes > ztcobc (itobc) ) 
     1124         !  This is not a problem ... 
     1125         nrecbef = idum 
     1126 
     1127      END FUNCTION nrecbef 
     1128 
     1129      !!============================================================================== 
     1130      SUBROUTINE obc_depth_average(nt_x) 
     1131         !!----------------------------------------------------------------------- 
     1132         !!                     ***    ROUTINE obc_depth_average   *** 
     1133         !! 
     1134         !!  Purpose : - compute the depth-averaged velocity from depth-dependent OBC frames 
     1135         !! 
     1136         !!    History : 2009-01 : ( Fred Dupont ) Original code 
     1137         !!----------------------------------------------------------------------- 
     1138 
     1139         ! * Arguments 
     1140         INTEGER, INTENT( in ) :: nt_x 
     1141 
     1142         ! * Local variables 
     1143         INTEGER :: ji, jj, jk 
     1144 
     1145 
     1146         IF( lp_obc_east ) THEN 
     1147            ! initialisation to zero 
     1148            ubtedta(:,nt_x) = 0.e0 
     1149            vbtedta(:,nt_x) = 0.e0 
     1150            DO ji = nie0, nie1 
     1151               DO jj = 1, jpj 
     1152                  DO jk = 1, jpkm1 
     1153                     ubtedta(jj,nt_x) = ubtedta(jj,nt_x) + uedta(jj,jk,nt_x)*fse3u(ji,jj,jk) 
     1154                     vbtedta(jj,nt_x) = vbtedta(jj,nt_x) + vedta(jj,jk,nt_x)*fse3v(ji+1,jj,jk) 
     1155                  END DO 
     1156               END DO 
     1157            END DO 
     1158         ENDIF 
     1159 
     1160         IF( lp_obc_west) THEN 
     1161            ! initialisation to zero 
     1162            ubtwdta(:,nt_x) = 0.e0 
     1163            vbtwdta(:,nt_x) = 0.e0 
     1164            DO ji = niw0, niw1 
     1165               DO jj = 1, jpj 
     1166                  DO jk = 1, jpkm1 
     1167                     ubtwdta(jj,nt_x) = ubtwdta(jj,nt_x) + uwdta(jj,jk,1)*fse3u(ji,jj,jk) 
     1168                     vbtwdta(jj,nt_x) = vbtwdta(jj,nt_x) + vwdta(jj,jk,1)*fse3v(ji,jj,jk) 
     1169                  END DO 
     1170               END DO 
     1171            END DO 
     1172         ENDIF 
     1173 
     1174         IF( lp_obc_north) THEN 
     1175            ! initialisation to zero 
     1176            ubtndta(:,nt_x) = 0.e0 
     1177            vbtndta(:,nt_x) = 0.e0 
     1178            DO jj = njn0, njn1 
     1179               DO ji = 1, jpi 
     1180                  DO jk = 1, jpkm1 
     1181                     ubtndta(ji,nt_x) = ubtndta(ji,nt_x) + undta(ji,jk,nt_x)*fse3u(ji,jj+1,jk) 
     1182                     vbtndta(ji,nt_x) = vbtndta(ji,nt_x) + vndta(ji,jk,nt_x)*fse3v(ji,jj,jk) 
     1183                  END DO 
     1184               END DO 
     1185            END DO 
     1186         ENDIF 
     1187 
     1188         IF( lp_obc_south) THEN 
     1189            ! initialisation to zero 
     1190            ubtsdta(:,nt_x) = 0.e0 
     1191            vbtsdta(:,nt_x) = 0.e0 
     1192            DO jj = njs0, njs1 
     1193               DO ji = nis0, nis1 
     1194                  DO jk = 1, jpkm1 
     1195                     ubtsdta(ji,nt_x) = ubtsdta(ji,nt_x) + usdta(ji,jk,nt_x)*fse3u(ji,jj,jk) 
     1196                     vbtsdta(ji,nt_x) = vbtsdta(ji,nt_x) + vsdta(ji,jk,nt_x)*fse3v(ji,jj,jk) 
     1197                  END DO 
     1198               END DO 
     1199            END DO 
     1200         ENDIF 
     1201 
     1202      END SUBROUTINE obc_depth_average 
    12821203 
    12831204#else 
    1284   !!------------------------------------------------------------------------------ 
    1285   !!   default option:           Dummy module          NO Open Boundary Conditions 
    1286   !!------------------------------------------------------------------------------ 
    1287 CONTAINS 
    1288   SUBROUTINE obc_dta( kt )             ! Dummy routine 
    1289     INTEGER, INTENT (in) :: kt 
    1290     WRITE(*,*) 'obc_dta: You should not have seen this print! error?', kt 
    1291   END SUBROUTINE obc_dta 
     1205      !!------------------------------------------------------------------------------ 
     1206      !!   default option:           Dummy module          NO Open Boundary Conditions 
     1207      !!------------------------------------------------------------------------------ 
     1208   CONTAINS 
     1209      SUBROUTINE obc_dta( kt )             ! Dummy routine 
     1210         INTEGER, INTENT (in) :: kt 
     1211         WRITE(*,*) 'obc_dta: You should not have seen this print! error?', kt 
     1212      END SUBROUTINE obc_dta 
    12921213#endif 
    1293 END MODULE obcdta 
     1214   END MODULE obcdta 
  • branches/DEV_r2106_LOCEAN2010/NEMO/OPA_SRC/OBC/obcdyn_bt.F90

    r1152 r2200  
    2323   USE lbclnk          ! ocean lateral boundary conditions (or mpp link) 
    2424   USE lib_mpp         ! distributed memory computing 
    25    USE obccli          ! ocean open boundary conditions: climatology 
     25   USE obcdta          ! ocean open boundary conditions 
    2626   USE in_out_manager  ! I/O manager 
    2727   USE dynspg_oce      ! surface pressure gradient     (free surface with time-splitting) 
     
    9999      !! * Local declaration 
    100100      INTEGER ::   ji, jj, jk ! dummy loop indices 
    101       REAL(wp) ::   z05cx, ztau, zin 
    102101      !!------------------------------------------------------------------------------ 
    103102 
     
    134133      !! * Local declaration 
    135134      INTEGER ::   ji, jj, jk ! dummy loop indices 
    136       REAL(wp) ::   z05cx, ztau, zin 
    137135      !!------------------------------------------------------------------------------ 
    138136 
     
    166164      !! * Local declaration 
    167165      INTEGER ::   ji, jj, jk ! dummy loop indices 
    168       REAL(wp) ::   z05cx, ztau, zin 
    169166      !!------------------------------------------------------------------------------ 
    170167 
     
    200197      !! * Local declaration 
    201198      INTEGER ::   ji, jj, jk ! dummy loop indices 
    202       REAL(wp) ::   z05cx, ztau, zin 
    203199 
    204200      !!------------------------------------------------------------------------------ 
     
    235231      !! * Local declaration 
    236232      INTEGER ::   ji, jj, jk ! dummy loop indices 
    237       REAL(wp) ::   z05cx, ztau, zin 
    238233      !!------------------------------------------------------------------------------ 
    239234 
     
    268263      !! * Local declaration 
    269264      INTEGER ::   ji, jj, jk ! dummy loop indices 
    270       REAL(wp) ::   z05cx, ztau, zin 
    271265      !!------------------------------------------------------------------------------ 
    272266 
     
    298292      !! * Local declaration 
    299293      INTEGER ::   ji, jj, jk ! dummy loop indices 
    300       REAL(wp) ::   z05cx, ztau, zin 
    301294      !!------------------------------------------------------------------------------ 
    302295 
     
    330323      !! * Local declaration 
    331324      INTEGER ::   ji, jj, jk ! dummy loop indices 
    332       REAL(wp) ::   z05cx, ztau, zin 
    333325 
    334326      !!------------------------------------------------------------------------------ 
  • branches/DEV_r2106_LOCEAN2010/NEMO/OPA_SRC/OBC/obcini.F90

    r1953 r2200  
    375375      END IF 
    376376 
    377       IF ( ln_vol_cst .OR. lk_dynspg_flt ) THEN 
    378         ! ... Initialize obcumask and obcvmask for the Force filtering  
    379         !     boundary condition in dynspg_flt 
    380         obcumask(:,:) = umask(:,:,1) 
    381         obcvmask(:,:) = vmask(:,:,1) 
    382  
    383         ! ... Initialize obctmsk on overlap region and obcs. This mask 
    384         !     is used in obcvol.F90 to calculate cumulate flux E-P.  
    385         !     obc Tracer point are outside the domain ( U/V obc points) ==> masked by obctmsk 
    386         !     - no flux E-P on obcs and overlap region (jpreci = jprecj = 1) 
    387         obctmsk(:,:) = tmask_i(:,:)      
    388  
    389         IF( lp_obc_east ) THEN 
    390            ! ... East obc Force filtering mask for the grad D 
    391            obcumask(nie0  :nie1  ,nje0p1:nje1m1) = 0.e0 
    392            obcvmask(nie0p1:nie1p1,nje0p1:nje1m1) = 0.e0 
    393            ! ... set to 0 on East OBC 
    394            obctmsk(nie0p1:nie1p1,nje0:nje1) = 0.e0 
    395         END IF 
    396    
    397         IF( lp_obc_west ) THEN 
    398            ! ... West obc Force filtering mask for the grad D 
    399            obcumask(niw0:niw1,njw0:njw1) = 0.e0 
    400            obcvmask(niw0:niw1,njw0:njw1) = 0.e0 
    401            ! ... set to 0 on West OBC 
    402            obctmsk(niw0:niw1,njw0:njw1) = 0.e0 
    403         END IF 
    404    
    405         IF( lp_obc_north ) THEN 
    406            ! ... North obc Force filtering mask for the grad D 
    407            obcumask(nin0p1:nin1m1,njn0p1:njn1p1) = 0.e0 
    408            obcvmask(nin0p1:nin1m1,njn0  :njn1  ) = 0.e0 
    409            ! ... set to 0 on North OBC 
    410            obctmsk(nin0:nin1,njn0p1:njn1p1) = 0.e0 
    411         END IF 
    412    
    413         IF( lp_obc_south ) THEN 
    414            ! ... South obc Force filtering mask for the grad D 
    415            obcumask(nis0p1:nis1m1,njs0:njs1) = 0.e0 
    416            obcvmask(nis0p1:nis1m1,njs0:njs1) = 0.e0 
    417            ! ... set to 0 on South OBC 
    418            obctmsk(nis0:nis1,njs0:njs1) = 0.e0 
    419         END IF 
    420       ENDIF 
    421  
    422       IF ( ln_vol_cst .OR. lk_dynspg_flt  ) THEN 
    423  
    424          ! 3.1 Total lateral surface  
    425          ! ------------------------- 
    426          obcsurftot = 0.e0 
    427    
    428          IF( lp_obc_east ) THEN ! ... East open boundary lateral surface 
    429             DO ji = nie0, nie1 
    430                DO jj = 1, jpj  
    431                   obcsurftot = obcsurftot+hu(ji,jj)*e2u(ji,jj)*uemsk(jj,1) * MAX(obctmsk(ji,jj),obctmsk(ji+1,jj) ) 
    432                END DO 
     377      ! ... Initialize obcumask and obcvmask for the Force filtering  
     378      !     boundary condition in dynspg_flt 
     379      obcumask(:,:) = umask(:,:,1) 
     380      obcvmask(:,:) = vmask(:,:,1) 
     381 
     382      ! ... Initialize obctmsk on overlap region and obcs. This mask 
     383      !     is used in obcvol.F90 to calculate cumulate flux E-P.  
     384      !     obc Tracer point are outside the domain ( U/V obc points) ==> masked by obctmsk 
     385      !     - no flux E-P on obcs and overlap region (jpreci = jprecj = 1) 
     386      obctmsk(:,:) = tmask_i(:,:)      
     387 
     388      IF( lp_obc_east ) THEN 
     389         ! ... East obc Force filtering mask for the grad D 
     390         obcumask(nie0  :nie1  ,nje0p1:nje1m1) = 0.e0 
     391         obcvmask(nie0p1:nie1p1,nje0p1:nje1m1) = 0.e0 
     392         ! ... set to 0 on East OBC 
     393         obctmsk(nie0p1:nie1p1,nje0:nje1) = 0.e0 
     394      END IF 
     395 
     396      IF( lp_obc_west ) THEN 
     397         ! ... West obc Force filtering mask for the grad D 
     398         obcumask(niw0:niw1,njw0:njw1) = 0.e0 
     399         obcvmask(niw0:niw1,njw0:njw1) = 0.e0 
     400         ! ... set to 0 on West OBC 
     401         obctmsk(niw0:niw1,njw0:njw1) = 0.e0 
     402      END IF 
     403 
     404      IF( lp_obc_north ) THEN 
     405         ! ... North obc Force filtering mask for the grad D 
     406         obcumask(nin0p1:nin1m1,njn0p1:njn1p1) = 0.e0 
     407         obcvmask(nin0p1:nin1m1,njn0  :njn1  ) = 0.e0 
     408         ! ... set to 0 on North OBC 
     409         obctmsk(nin0:nin1,njn0p1:njn1p1) = 0.e0 
     410      END IF 
     411 
     412      IF( lp_obc_south ) THEN 
     413         ! ... South obc Force filtering mask for the grad D 
     414         obcumask(nis0p1:nis1m1,njs0:njs1) = 0.e0 
     415         obcvmask(nis0p1:nis1m1,njs0:njs1) = 0.e0 
     416         ! ... set to 0 on South OBC 
     417         obctmsk(nis0:nis1,njs0:njs1) = 0.e0 
     418      END IF 
     419 
     420      ! 3.1 Total lateral surface  
     421      ! ------------------------- 
     422      obcsurftot = 0.e0 
     423 
     424      IF( lp_obc_east ) THEN ! ... East open boundary lateral surface 
     425         DO ji = nie0, nie1 
     426            DO jj = 1, jpj  
     427               obcsurftot = obcsurftot+hu(ji,jj)*e2u(ji,jj)*uemsk(jj,1) * MAX(obctmsk(ji,jj),obctmsk(ji+1,jj) ) 
    433428            END DO 
    434          END IF 
    435    
    436          IF( lp_obc_west ) THEN ! ... West open boundary lateral surface 
    437             DO ji = niw0, niw1 
    438                DO jj = 1, jpj  
    439                   obcsurftot = obcsurftot+hu(ji,jj)*e2u(ji,jj)*uwmsk(jj,1) * MAX(obctmsk(ji,jj),obctmsk(ji+1,jj) ) 
    440                END DO 
     429         END DO 
     430      END IF 
     431 
     432      IF( lp_obc_west ) THEN ! ... West open boundary lateral surface 
     433         DO ji = niw0, niw1 
     434            DO jj = 1, jpj  
     435               obcsurftot = obcsurftot+hu(ji,jj)*e2u(ji,jj)*uwmsk(jj,1) * MAX(obctmsk(ji,jj),obctmsk(ji+1,jj) ) 
    441436            END DO 
    442          END IF 
    443  
    444          IF( lp_obc_north ) THEN ! ... North open boundary lateral surface 
    445             DO jj = njn0, njn1 
    446                DO ji = 1, jpi 
    447                   obcsurftot = obcsurftot+hv(ji,jj)*e1v(ji,jj)*vnmsk(ji,1) * MAX(obctmsk(ji,jj),obctmsk(ji,jj+1) ) 
    448                END DO 
     437         END DO 
     438      END IF 
     439 
     440      IF( lp_obc_north ) THEN ! ... North open boundary lateral surface 
     441         DO jj = njn0, njn1 
     442            DO ji = 1, jpi 
     443               obcsurftot = obcsurftot+hv(ji,jj)*e1v(ji,jj)*vnmsk(ji,1) * MAX(obctmsk(ji,jj),obctmsk(ji,jj+1) ) 
    449444            END DO 
    450          END IF 
    451    
    452          IF( lp_obc_south ) THEN ! ... South open boundary lateral surface 
    453             DO jj = njs0, njs1 
    454                DO ji = 1, jpi 
    455                   obcsurftot = obcsurftot+hv(ji,jj)*e1v(ji,jj)*vsmsk(ji,1) * MAX(obctmsk(ji,jj),obctmsk(ji,jj+1) ) 
    456                END DO 
     445         END DO 
     446      END IF 
     447 
     448      IF( lp_obc_south ) THEN ! ... South open boundary lateral surface 
     449         DO jj = njs0, njs1 
     450            DO ji = 1, jpi 
     451               obcsurftot = obcsurftot+hv(ji,jj)*e1v(ji,jj)*vsmsk(ji,1) * MAX(obctmsk(ji,jj),obctmsk(ji,jj+1) ) 
    457452            END DO 
    458          END IF 
    459    
    460          IF( lk_mpp )   CALL mpp_sum( obcsurftot )   ! sum over the global domain 
    461       ENDIF 
     453         END DO 
     454      END IF 
     455 
     456      IF( lk_mpp )   CALL mpp_sum( obcsurftot )   ! sum over the global domain 
    462457 
    463458      ! 5. Control print on mask  
  • branches/DEV_r2106_LOCEAN2010/NEMO/OPA_SRC/OBC/obcrad.F90

    r1528 r2200  
    115115      ! ------------------- 
    116116 
    117       IF( kt > nit000 ) THEN  
     117      IF( kt > nit000 .OR. ln_rstart ) THEN  
    118118 
    119119         ! ... advance in time (time filter, array swap)  
     
    379379      ! ------------------- 
    380380 
    381       IF( kt > nit000 ) THEN 
     381      IF( kt > nit000 .OR. ln_rstart ) THEN 
    382382 
    383383         ! ... advance in time (time filter, array swap)  
     
    648648      ! ------------------- 
    649649 
    650       IF( kt > nit000 ) THEN  
     650      IF( kt > nit000 .OR. ln_rstart ) THEN  
    651651 
    652652         ! ... advance in time (time filter, array swap) 
     
    922922      ! -------------------- 
    923923   
    924       IF( kt > nit000) THEN  
     924      IF( kt > nit000 .OR. ln_rstart ) THEN  
    925925 
    926926         ! ... advance in time (time filter, array swap) 
  • branches/DEV_r2106_LOCEAN2010/NEMO/OPA_SRC/OBC/obcrst.F90

    r1953 r2200  
    278278      !! * Local declarations 
    279279      INTEGER ::   inum = 11            ! temporary logical unit 
    280       INTEGER ::   ji,jj,jk,ios 
     280      INTEGER ::   ji,jj,jk 
    281281      INTEGER ::   ino0,it0,nbobc0,jpieob0,jpiwob0,jpjnob0,jpjsob0 
    282282      INTEGER ::   ino1,it1,nbobc1,jpieob1,jpiwob1,jpjnob1,jpjsob1 
  • branches/DEV_r2106_LOCEAN2010/NEMO/OPA_SRC/SBC/sbcana.F90

    r1976 r2200  
    8888         ! 
    8989         nn_tau000 = MAX( nn_tau000, 1 )   ! must be >= 1 
    90          qns   (:,:) = rn_qns0 
    91          qsr   (:,:) = rn_qsr0 
    92          emp   (:,:) = rn_emp0 
    93          emps  (:,:) = rn_emp0 
    9490         ! 
    9591      ENDIF 
     92 
     93      qns   (:,:) = rn_qns0 
     94      qsr   (:,:) = rn_qsr0 
     95      emp   (:,:) = rn_emp0 
     96      emps  (:,:) = rn_emp0 
    9697    
    9798      ! Increase the surface stress to its nominal value during the first nn_tau000 time-steps 
  • branches/DEV_r2106_LOCEAN2010/NEMO/OPA_SRC/opa.F90

    r2148 r2200  
    175175      !                             !--------------------------------------------! 
    176176#if defined key_iomput 
     177      IF( Agrif_Root() ) THEN 
    177178# if defined key_oasis3 || defined key_oasis4 
    178       CALL cpl_prism_init( ilocal_comm )      ! nemo local communicator given by oasis 
    179       CALL init_ioclient()                    ! io_server will get its communicators (if needed) from oasis (we don't see it) 
    180 # else 
    181       CALL init_ioclient( ilocal_comm )       ! nemo local communicator (used or not) given by the io_server 
     179         CALL cpl_prism_init( ilocal_comm )   ! nemo local communicator given by oasis 
    182180# endif 
     181         CALL  init_ioclient( ilocal_comm )   ! exchange io_server nemo local communicator with the io_server 
     182      ENDIF 
    183183      narea = mynode( cltxt, ilocal_comm )    ! Nodes selection 
    184  
    185184#else 
    186185# if defined key_oasis3 || defined key_oasis4 
  • branches/DEV_r2106_LOCEAN2010/NEMO/OPA_SRC/step.F90

    r2148 r2200  
    8282#endif    
    8383                             indic = 0                ! reset to no error condition 
    84       IF( kstp /= nit000 )   CALL day      ( kstp )   ! Calendar (day was already called at nit000 in day_init) 
     84      IF( kstp /= nit000 )   CALL day( kstp )         ! Calendar (day was already called at nit000 in day_init) 
    8585                             CALL iom_setkt( kstp )   ! say to iom that we are at time step kstp 
    86                              CALL rst_opn  ( kstp )   ! Open the restart file 
    8786 
    8887      !>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>> 
Note: See TracChangeset for help on using the changeset viewer.