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 8817 for branches/2017/dev_r7881_ENHANCE09_RK3/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90 – NEMO

Ignore:
Timestamp:
2017-11-27T12:03:07+01:00 (7 years ago)
Author:
clem
Message:

make ice restart file shorter (this commit is on behalf of Madec)

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/2017/dev_r7881_ENHANCE09_RK3/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90

    r8586 r8817  
    11MODULE iom 
    2    !!===================================================================== 
     2   !!====================================================================== 
    33   !!                    ***  MODULE  iom *** 
    44   !! Input/Output manager :  Library to read input files 
    5    !!==================================================================== 
     5   !!====================================================================== 
    66   !! History :  2.0  ! 2005-12  (J. Belier) Original code 
    77   !!            2.0  ! 2006-02  (S. Masson) Adaptation to NEMO 
     
    1010   !!            3.6  ! 2014-15  DIMG format removed 
    1111   !!            3.6  ! 2015-15  (J. Harle) Added procedure to read REAL attributes 
    12    !!-------------------------------------------------------------------- 
    13  
    14    !!-------------------------------------------------------------------- 
     12   !!            4.0  ! 2017-11  (M. Andrejczuk) Extend IOM interface to write any 3D fields 
     13   !!---------------------------------------------------------------------- 
     14 
     15   !!---------------------------------------------------------------------- 
    1516   !!   iom_open       : open a file read only 
    1617   !!   iom_close      : close a file or all files opened by iom 
     
    1920   !!   iom_varid      : get the id of a variable in a file 
    2021   !!   iom_rstput     : write a field in a restart file (interfaced to several routines) 
    21    !!-------------------------------------------------------------------- 
     22   !!---------------------------------------------------------------------- 
    2223   USE dom_oce         ! ocean space and time domain 
    2324   USE c1d             ! 1D vertical configuration 
     
    2930   USE lib_mpp           ! MPP library 
    3031#if defined key_iomput 
    31    USE sbc_oce, ONLY :   nn_fsbc         ! ocean space and time domain 
    32    USE trc_oce, ONLY :   nn_dttrc        !  !: frequency of step on passive tracers 
    33    USE icb_oce, ONLY :   nclasses, class_num       !  !: iceberg classes 
     32   USE sbc_oce  , ONLY :   nn_fsbc         ! ocean space and time domain 
     33   USE trc_oce  , ONLY :   nn_dttrc        !  !: frequency of step on passive tracers 
     34   USE icb_oce  , ONLY :   nclasses, class_num       !  !: iceberg classes 
    3435#if defined key_lim3 
    35    USE ice    , ONLY :   jpl 
     36   USE ice      , ONLY :   jpl 
    3637#endif 
    3738   USE domngb          ! ocean space and time domain 
     
    8081 
    8182   !!---------------------------------------------------------------------- 
    82    !! NEMO/OPA 3.3 , NEMO Consortium (2010) 
     83   !! NEMO/OPA 4.0 , NEMO Consortium (2017) 
    8384   !! $Id$ 
    8485   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt) 
    8586   !!---------------------------------------------------------------------- 
    86  
    8787CONTAINS 
    8888 
     
    9595      !!---------------------------------------------------------------------- 
    9696      CHARACTER(len=*), INTENT(in)  :: cdname 
     97      ! 
    9798#if defined key_iomput 
    98  
     99      ! 
    99100      TYPE(xios_duration) :: dtime    = xios_duration(0, 0, 0, 0, 0, 0) 
    100101      TYPE(xios_date)     :: start_date 
     
    104105      REAL(wp), ALLOCATABLE, DIMENSION(:,:) :: zt_bnds, zw_bnds 
    105106      !!---------------------------------------------------------------------- 
    106  
     107      ! 
    107108      ALLOCATE( zt_bnds(2,jpk), zw_bnds(2,jpk) ) 
    108  
     109      ! 
    109110      clname = cdname 
    110111      IF( TRIM(Agrif_CFixed()) /= '0' )   clname = TRIM(Agrif_CFixed())//"_"//TRIM(cdname) 
     
    125126      ! horizontal grid definition 
    126127      CALL set_scalar 
    127  
     128      ! 
    128129      IF( TRIM(cdname) == TRIM(cxios_context) ) THEN   
    129130         CALL set_grid( "T", glamt, gphit )  
     
    144145         ENDIF 
    145146      ENDIF 
    146  
     147      ! 
    147148      IF( TRIM(cdname) == TRIM(cxios_context)//"_crs" ) THEN   
    148149         CALL dom_grid_crs   ! Save the parent grid information  & Switch to coarse grid domain 
     
    167168         ENDIF 
    168169      ENDIF 
    169  
     170      ! 
    170171      ! vertical grid definition 
    171172      CALL iom_set_axis_attr( "deptht", gdept_1d ) 
     
    173174      CALL iom_set_axis_attr( "depthv", gdept_1d ) 
    174175      CALL iom_set_axis_attr( "depthw", gdepw_1d ) 
    175  
     176      ! 
    176177      ! Add vertical grid bounds 
    177178      jkmin = MIN(2,jpk)  ! in case jpk=1 (i.e. sas2D) 
     
    186187      CALL iom_set_axis_attr( "depthv", bounds=zt_bnds ) 
    187188      CALL iom_set_axis_attr( "depthw", bounds=zw_bnds ) 
    188  
    189  
     189      ! 
    190190# if defined key_floats 
    191191      CALL iom_set_axis_attr( "nfloat", (/ (REAL(ji,wp), ji=1,nfloat) /) ) 
    192192# endif 
    193 #if defined key_lim3 
     193# if defined key_lim3 
    194194      CALL iom_set_axis_attr( "ncatice", (/ (REAL(ji,wp), ji=1,jpl) /) ) 
    195195      ! SIMIP diagnostics (4 main arctic straits) 
    196196      CALL iom_set_axis_attr( "nstrait", (/ (REAL(ji,wp), ji=1,4) /) ) 
    197 #endif 
     197# endif 
    198198      CALL iom_set_axis_attr( "icbcla", class_num ) 
    199199      CALL iom_set_axis_attr( "iax_20C", (/ REAL(20,wp) /) ) 
     
    202202      ! automatic definitions of some of the xml attributs 
    203203      CALL set_xmlatt 
    204  
     204      ! 
    205205      ! end file definition 
    206206      dtime%second = rdt 
     
    209209       
    210210      CALL xios_update_calendar(0) 
    211  
     211      ! 
    212212      DEALLOCATE( zt_bnds, zw_bnds ) 
    213  
     213      ! 
    214214#endif 
    215        
     215      ! 
    216216   END SUBROUTINE iom_init 
    217217 
     
    239239 
    240240 
    241    SUBROUTINE iom_open( cdname, kiomid, ldwrt, kdom, kiolib, ldstop, ldiof ) 
     241   SUBROUTINE iom_open( cdname, kiomid, ldwrt, kdom, kiolib, ldstop, ldiof, kdlev ) 
    242242      !!--------------------------------------------------------------------- 
    243243      !!                   ***  SUBROUTINE  iom_open  *** 
     
    252252      LOGICAL         , INTENT(in   ), OPTIONAL ::   ldstop   ! stop if open to read a non-existing file (default = .TRUE.) 
    253253      LOGICAL         , INTENT(in   ), OPTIONAL ::   ldiof    ! Interp On the Fly, needed for AGRIF (default = .FALSE.) 
     254      INTEGER         , INTENT(in   ), OPTIONAL ::   kdlev    ! number of vertical levels 
    254255 
    255256      CHARACTER(LEN=256)    ::   clname    ! the name of the file based on cdname [[+clcpu]+clcpu] 
     
    405406      IF( istop == nstop ) THEN   ! no error within this routine 
    406407         SELECT CASE (iolib) 
    407          CASE (jpnf90   )   ;   CALL iom_nf90_open(    clname, kiomid, llwrt, llok, idompar ) 
     408         CASE (jpnf90   )   ;   CALL iom_nf90_open(    clname, kiomid, llwrt, llok, idompar, kdlev = kdlev ) 
    408409         CASE DEFAULT 
    409410            CALL ctl_stop( TRIM(clinfo)//' accepted IO library is only jpnf90 (jpioipsl option has been removed) ' ) 
     
    672673      CHARACTER(LEN=1)               ::   clrankpv, cldmspc      !  
    673674      LOGICAL                        ::   ll_depth_spec ! T => if kstart, kcount present then *only* use values for 3rd spatial dimension. 
     675      INTEGER                        ::   inlev       ! number of levels for 3D data 
    674676      !--------------------------------------------------------------------- 
    675677      ! 
     678      inlev = -1 
     679      IF( PRESENT(pv_r3d) )   inlev = SIZE(pv_r3d, 3) 
    676680      clname = iom_file(kiomid)%name   !   esier to read 
    677681      clinfo = '          iom_get_123d, file: '//trim(clname)//', var: '//trim(cdvar) 
     
    774778         istart(idmspc+1) = itime 
    775779 
    776          IF( PRESENT(kstart) .AND. .NOT. ll_depth_spec ) THEN ; istart(1:idmspc) = kstart(1:idmspc) ; icnt(1:idmspc) = kcount(1:idmspc) 
     780         IF( PRESENT(kstart) .AND. .NOT. ll_depth_spec ) THEN  
     781            istart(1:idmspc) = kstart(1:idmspc)  
     782            icnt(1:idmspc) = kcount(1:idmspc) 
    777783         ELSE 
    778             IF(           idom == jpdom_unknown ) THEN                                                ; icnt(1:idmspc) = idimsz(1:idmspc) 
     784            IF(idom == jpdom_unknown ) THEN 
     785               icnt(1:idmspc) = idimsz(1:idmspc) 
    779786            ELSE  
    780787               IF( .NOT. PRESENT(pv_r1d) ) THEN   !   not a 1D array 
     
    799806                  ENDIF 
    800807                  IF( PRESENT(pv_r3d) ) THEN 
    801                      IF( idom == jpdom_data ) THEN                                  ; icnt(3) = jpkglo 
     808                     IF( idom == jpdom_data ) THEN                                  ; icnt(3) = inlev 
    802809                     ELSE IF( ll_depth_spec .AND. PRESENT(kstart) ) THEN            ; istart(3) = kstart(3); icnt(3) = kcount(3) 
    803                      ELSE                                                           ; icnt(3) = jpk 
     810                     ELSE                                                           ; icnt(3) = inlev 
    804811                     ENDIF 
    805812                  ENDIF 
     
    884891            ELSEIF( PRESENT(pv_r3d) .AND. idom /= jpdom_unknown ) THEN 
    885892               ! this if could be simplified with the new lbc_lnk that works with any size of the 3rd dimension 
    886                IF( icnt(3) == jpk ) THEN 
     893               IF( icnt(3) == inlev ) THEN 
    887894                  CALL lbc_lnk( pv_r3d,'Z',-999.,'no0' ) 
    888895               ELSE   ! put some arbitrary value (a call to lbc_lnk will be done later...) 
     
    11331140   END SUBROUTINE iom_rp0d 
    11341141 
     1142 
    11351143   SUBROUTINE iom_rp1d( kt, kwrite, kiomid, cdvar, pvar, ktype ) 
    11361144      INTEGER         , INTENT(in)                         ::   kt       ! ocean time-step 
     
    11531161   END SUBROUTINE iom_rp1d 
    11541162 
     1163 
    11551164   SUBROUTINE iom_rp2d( kt, kwrite, kiomid, cdvar, pvar, ktype ) 
    11561165      INTEGER         , INTENT(in)                         ::   kt       ! ocean time-step 
     
    11731182   END SUBROUTINE iom_rp2d 
    11741183 
     1184 
    11751185   SUBROUTINE iom_rp3d( kt, kwrite, kiomid, cdvar, pvar, ktype ) 
    11761186      INTEGER         , INTENT(in)                         ::   kt       ! ocean time-step 
     
    12341244      REAL(wp),       DIMENSION(:,:,:), INTENT(in) ::   pfield3d 
    12351245#if defined key_iomput 
    1236       CALL xios_send_field(cdname, pfield3d) 
     1246      CALL xios_send_field( cdname, pfield3d ) 
    12371247#else 
    12381248      IF( .FALSE. )   WRITE(numout,*) cdname, pfield3d   ! useless test to avoid compilation warnings 
    12391249#endif 
    12401250   END SUBROUTINE iom_p3d 
     1251 
     1252#if defined key_iomput 
     1253 
    12411254   !!---------------------------------------------------------------------- 
    1242  
    1243 #if defined key_iomput 
     1255   !!   'key_iomput'                                         IOM  interface 
     1256   !!---------------------------------------------------------------------- 
    12441257 
    12451258   SUBROUTINE iom_set_domain_attr( cdid, ni_glo, nj_glo, ibegin, jbegin, ni, nj, zoom_ibegin, zoom_jbegin, zoom_ni, zoom_nj,   & 
    12461259      &                                    data_dim, data_ibegin, data_ni, data_jbegin, data_nj, lonvalue, latvalue, mask,     & 
    12471260      &                                    nvertex, bounds_lon, bounds_lat, area ) 
    1248       CHARACTER(LEN=*)                   , INTENT(in) ::   cdid 
    1249       INTEGER                  , OPTIONAL, INTENT(in) ::   ni_glo, nj_glo, ibegin, jbegin, ni, nj 
    1250       INTEGER                  , OPTIONAL, INTENT(in) ::   data_dim, data_ibegin, data_ni, data_jbegin, data_nj 
    1251       INTEGER                  , OPTIONAL, INTENT(in) ::   zoom_ibegin, zoom_jbegin, zoom_ni, zoom_nj, nvertex 
    1252       REAL(wp), DIMENSION(:)   , OPTIONAL, INTENT(in) ::   lonvalue, latvalue 
    1253       REAL(wp), DIMENSION(:,:) , OPTIONAL, INTENT(in) ::   bounds_lon, bounds_lat, area 
    1254       LOGICAL, DIMENSION(:)   , OPTIONAL, INTENT(in) ::   mask 
    1255  
    1256  
    1257       IF ( xios_is_valid_domain     (cdid) ) THEN 
     1261      !!---------------------------------------------------------------------- 
     1262      !!---------------------------------------------------------------------- 
     1263      CHARACTER(LEN=*)                  , INTENT(in) ::   cdid 
     1264      INTEGER                 , OPTIONAL, INTENT(in) ::   ni_glo, nj_glo, ibegin, jbegin, ni, nj 
     1265      INTEGER                 , OPTIONAL, INTENT(in) ::   data_dim, data_ibegin, data_ni, data_jbegin, data_nj 
     1266      INTEGER                 , OPTIONAL, INTENT(in) ::   zoom_ibegin, zoom_jbegin, zoom_ni, zoom_nj, nvertex 
     1267      REAL(wp), DIMENSION(:)  , OPTIONAL, INTENT(in) ::   lonvalue, latvalue 
     1268      REAL(wp), DIMENSION(:,:), OPTIONAL, INTENT(in) ::   bounds_lon, bounds_lat, area 
     1269      LOGICAL , DIMENSION(:)  , OPTIONAL, INTENT(in) ::   mask 
     1270      !!---------------------------------------------------------------------- 
     1271      ! 
     1272      IF( xios_is_valid_domain     (cdid) ) THEN 
    12581273         CALL xios_set_domain_attr     ( cdid, ni_glo=ni_glo, nj_glo=nj_glo, ibegin=ibegin, jbegin=jbegin, ni=ni, nj=nj,   & 
    12591274            &    data_dim=data_dim, data_ibegin=data_ibegin, data_ni=data_ni, data_jbegin=data_jbegin, data_nj=data_nj ,   & 
     
    12611276            &    bounds_lat_1D=bounds_lat, area=area, type='curvilinear') 
    12621277     ENDIF 
    1263       IF ( xios_is_valid_domaingroup(cdid) ) THEN 
     1278      IF( xios_is_valid_domaingroup(cdid) ) THEN 
    12641279         CALL xios_set_domaingroup_attr( cdid, ni_glo=ni_glo, nj_glo=nj_glo, ibegin=ibegin, jbegin=jbegin, ni=ni, nj=nj,   & 
    12651280            &    data_dim=data_dim, data_ibegin=data_ibegin, data_ni=data_ni, data_jbegin=data_jbegin, data_nj=data_nj ,   & 
     
    12671282            &    bounds_lat_1D=bounds_lat, area=area, type='curvilinear' ) 
    12681283      ENDIF 
    1269  
     1284      ! 
    12701285      CALL xios_solve_inheritance() 
    1271  
     1286      ! 
    12721287   END SUBROUTINE iom_set_domain_attr 
    12731288 
    12741289 
    1275    SUBROUTINE iom_set_zoom_domain_attr( cdid, ibegin, jbegin, ni, nj) 
    1276       CHARACTER(LEN=*)                   , INTENT(in) ::   cdid 
    1277       INTEGER                  , OPTIONAL, INTENT(in) ::   ibegin, jbegin, ni, nj 
    1278  
    1279       IF ( xios_is_valid_zoom_domain     (cdid) ) THEN 
    1280           CALL xios_set_zoom_domain_attr     ( cdid, ibegin=ibegin, jbegin=jbegin, ni=ni,    & 
    1281             &   nj=nj) 
    1282      ENDIF 
     1290   SUBROUTINE iom_set_zoom_domain_attr( cdid, ibegin, jbegin, ni, nj ) 
     1291      !!---------------------------------------------------------------------- 
     1292      !!---------------------------------------------------------------------- 
     1293      CHARACTER(LEN=*)          , INTENT(in) ::   cdid 
     1294      INTEGER         , OPTIONAL, INTENT(in) ::   ibegin, jbegin, ni, nj 
     1295      !!---------------------------------------------------------------------- 
     1296      IF( xios_is_valid_zoom_domain(cdid) )   CALL xios_set_zoom_domain_attr( cdid, ibegin=ibegin, jbegin=jbegin, ni=ni, nj=nj ) 
    12831297   END SUBROUTINE iom_set_zoom_domain_attr 
    12841298 
    12851299 
    12861300   SUBROUTINE iom_set_axis_attr( cdid, paxis, bounds ) 
     1301      !!---------------------------------------------------------------------- 
     1302      !!---------------------------------------------------------------------- 
    12871303      CHARACTER(LEN=*)      , INTENT(in) ::   cdid 
    12881304      REAL(wp), DIMENSION(:)  , OPTIONAL, INTENT(in) ::   paxis 
    12891305      REAL(wp), DIMENSION(:,:), OPTIONAL, INTENT(in) ::   bounds 
    1290  
    1291       IF ( PRESENT(paxis) ) THEN 
    1292          IF ( xios_is_valid_axis     (cdid) )   CALL xios_set_axis_attr     ( cdid, n_glo=SIZE(paxis), value=paxis ) 
    1293          IF ( xios_is_valid_axisgroup(cdid) )   CALL xios_set_axisgroup_attr( cdid, n_glo=SIZE(paxis), value=paxis ) 
    1294       ENDIF 
    1295       IF ( xios_is_valid_axis     (cdid) )   CALL xios_set_axis_attr     ( cdid, bounds=bounds ) 
    1296       IF ( xios_is_valid_axisgroup(cdid) )   CALL xios_set_axisgroup_attr( cdid, bounds=bounds ) 
     1306      !!---------------------------------------------------------------------- 
     1307      IF( PRESENT(paxis) ) THEN 
     1308         IF( xios_is_valid_axis     (cdid) )   CALL xios_set_axis_attr     ( cdid, n_glo=SIZE(paxis), value=paxis ) 
     1309         IF( xios_is_valid_axisgroup(cdid) )   CALL xios_set_axisgroup_attr( cdid, n_glo=SIZE(paxis), value=paxis ) 
     1310      ENDIF 
     1311      IF( xios_is_valid_axis     (cdid) )   CALL xios_set_axis_attr     ( cdid, bounds=bounds ) 
     1312      IF( xios_is_valid_axisgroup(cdid) )   CALL xios_set_axisgroup_attr( cdid, bounds=bounds ) 
    12971313      CALL xios_solve_inheritance() 
    12981314   END SUBROUTINE iom_set_axis_attr 
     
    13001316 
    13011317   SUBROUTINE iom_set_field_attr( cdid, freq_op, freq_offset ) 
    1302       CHARACTER(LEN=*)          , INTENT(in) ::   cdid 
    1303       TYPE(xios_duration),OPTIONAL , INTENT(in) ::   freq_op 
    1304       TYPE(xios_duration),OPTIONAL , INTENT(in) ::   freq_offset 
    1305       IF ( xios_is_valid_field     (cdid) )   CALL xios_set_field_attr       & 
    1306     &     ( cdid, freq_op=freq_op, freq_offset=freq_offset ) 
    1307       IF ( xios_is_valid_fieldgroup(cdid) )   CALL xios_set_fieldgroup_attr  & 
    1308     &                    ( cdid, freq_op=freq_op, freq_offset=freq_offset ) 
     1318      !!---------------------------------------------------------------------- 
     1319      !!---------------------------------------------------------------------- 
     1320      CHARACTER(LEN=*)             , INTENT(in) ::   cdid 
     1321      TYPE(xios_duration), OPTIONAL, INTENT(in) ::   freq_op 
     1322      TYPE(xios_duration), OPTIONAL, INTENT(in) ::   freq_offset 
     1323      !!---------------------------------------------------------------------- 
     1324      IF( xios_is_valid_field     (cdid) )   CALL xios_set_field_attr     ( cdid, freq_op=freq_op, freq_offset=freq_offset ) 
     1325      IF( xios_is_valid_fieldgroup(cdid) )   CALL xios_set_fieldgroup_attr( cdid, freq_op=freq_op, freq_offset=freq_offset ) 
    13091326      CALL xios_solve_inheritance() 
    13101327   END SUBROUTINE iom_set_field_attr 
     
    13121329 
    13131330   SUBROUTINE iom_set_file_attr( cdid, name, name_suffix ) 
     1331      !!---------------------------------------------------------------------- 
     1332      !!---------------------------------------------------------------------- 
    13141333      CHARACTER(LEN=*)          , INTENT(in) ::   cdid 
    13151334      CHARACTER(LEN=*),OPTIONAL , INTENT(in) ::   name, name_suffix 
    1316       IF ( xios_is_valid_file     (cdid) )   CALL xios_set_file_attr     ( cdid, name=name, name_suffix=name_suffix ) 
    1317       IF ( xios_is_valid_filegroup(cdid) )   CALL xios_set_filegroup_attr( cdid, name=name, name_suffix=name_suffix ) 
     1335      !!---------------------------------------------------------------------- 
     1336      IF( xios_is_valid_file     (cdid) )   CALL xios_set_file_attr     ( cdid, name=name, name_suffix=name_suffix ) 
     1337      IF( xios_is_valid_filegroup(cdid) )   CALL xios_set_filegroup_attr( cdid, name=name, name_suffix=name_suffix ) 
    13181338      CALL xios_solve_inheritance() 
    13191339   END SUBROUTINE iom_set_file_attr 
     
    13211341 
    13221342   SUBROUTINE iom_get_file_attr( cdid, name, name_suffix, output_freq ) 
     1343      !!---------------------------------------------------------------------- 
     1344      !!---------------------------------------------------------------------- 
    13231345      CHARACTER(LEN=*)          , INTENT(in ) ::   cdid 
    13241346      CHARACTER(LEN=*),OPTIONAL , INTENT(out) ::   name, name_suffix 
     
    13291351      IF( PRESENT( name_suffix ) )   name_suffix = '' 
    13301352      IF( PRESENT( output_freq ) )   output_freq = xios_duration(0,0,0,0,0,0) 
    1331       IF ( xios_is_valid_file     (cdid) ) THEN 
     1353      IF( xios_is_valid_file     (cdid) ) THEN 
    13321354         CALL xios_solve_inheritance() 
    13331355         CALL xios_is_defined_file_attr     ( cdid, name = llexist1, name_suffix = llexist2, output_freq = llexist3) 
     
    13361358         IF(llexist3)   CALL xios_get_file_attr     ( cdid, output_freq = output_freq ) 
    13371359      ENDIF 
    1338       IF ( xios_is_valid_filegroup(cdid) ) THEN 
     1360      IF( xios_is_valid_filegroup(cdid) ) THEN 
    13391361         CALL xios_solve_inheritance() 
    13401362         CALL xios_is_defined_filegroup_attr( cdid, name = llexist1, name_suffix = llexist2, output_freq = llexist3) 
     
    13471369 
    13481370   SUBROUTINE iom_set_grid_attr( cdid, mask ) 
     1371      !!---------------------------------------------------------------------- 
     1372      !!---------------------------------------------------------------------- 
    13491373      CHARACTER(LEN=*)                   , INTENT(in) ::   cdid 
    13501374      LOGICAL, DIMENSION(:,:,:), OPTIONAL, INTENT(in) ::   mask 
    1351       IF ( xios_is_valid_grid     (cdid) )   CALL xios_set_grid_attr     ( cdid, mask_3D=mask ) 
    1352       IF ( xios_is_valid_gridgroup(cdid) )   CALL xios_set_gridgroup_attr( cdid, mask_3D=mask ) 
     1375      !!---------------------------------------------------------------------- 
     1376      IF( xios_is_valid_grid     (cdid) )   CALL xios_set_grid_attr     ( cdid, mask_3D=mask ) 
     1377      IF( xios_is_valid_gridgroup(cdid) )   CALL xios_set_gridgroup_attr( cdid, mask_3D=mask ) 
    13531378      CALL xios_solve_inheritance() 
    13541379   END SUBROUTINE iom_set_grid_attr 
    13551380 
    13561381   SUBROUTINE iom_setkt( kt, cdname ) 
     1382      !!---------------------------------------------------------------------- 
     1383      !!---------------------------------------------------------------------- 
    13571384      INTEGER         , INTENT(in) ::   kt  
    13581385      CHARACTER(LEN=*), INTENT(in) ::   cdname 
    1359       !      
     1386      !!---------------------------------------------------------------------- 
    13601387      CALL iom_swap( cdname )   ! swap to cdname context 
    13611388      CALL xios_update_calendar(kt) 
    1362       IF( cdname /= TRIM(cxios_context) ) CALL iom_swap( TRIM(cxios_context) )   ! return back to nemo context 
    1363       ! 
     1389      IF( cdname /= TRIM(cxios_context) )   CALL iom_swap( TRIM(cxios_context) )   ! return back to nemo context 
    13641390   END SUBROUTINE iom_setkt 
    13651391 
    13661392   SUBROUTINE iom_context_finalize( cdname ) 
     1393      !!---------------------------------------------------------------------- 
     1394      !!---------------------------------------------------------------------- 
    13671395      CHARACTER(LEN=*), INTENT(in) :: cdname 
    1368       ! 
     1396      !!---------------------------------------------------------------------- 
    13691397      IF( xios_is_valid_context(cdname) ) THEN 
    13701398         CALL iom_swap( cdname )   ! swap to cdname context 
     
    13721400         IF( cdname /= TRIM(cxios_context) ) CALL iom_swap( TRIM(cxios_context) )   ! return back to nemo context 
    13731401      ENDIF 
    1374       ! 
    13751402   END SUBROUTINE iom_context_finalize 
    13761403 
     
    13811408      !! 
    13821409      !! ** Purpose :   define horizontal grids 
    1383       !! 
    13841410      !!---------------------------------------------------------------------- 
    13851411      CHARACTER(LEN=1)            , INTENT(in) ::   cdgrd 
     
    13871413      REAL(wp), DIMENSION(jpi,jpj), INTENT(in) ::   plat 
    13881414      ! 
     1415      INTEGER  :: ni,nj 
    13891416      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zmask 
    1390       INTEGER  :: ni,nj 
    1391        
     1417      !!---------------------------------------------------------------------- 
     1418      ! 
    13921419      ni=nlei-nldi+1 ; nj=nlej-nldj+1 
    1393  
     1420      ! 
    13941421      CALL iom_set_domain_attr("grid_"//cdgrd, ni_glo=jpiglo, nj_glo=jpjglo, ibegin=nimpp+nldi-2, jbegin=njmpp+nldj-2, ni=ni, nj=nj) 
    13951422      CALL iom_set_domain_attr("grid_"//cdgrd, data_dim=2, data_ibegin = 1-nldi, data_ni = jpi, data_jbegin = 1-nldj, data_nj = jpj) 
    13961423      CALL iom_set_domain_attr("grid_"//cdgrd, lonvalue = RESHAPE(plon(nldi:nlei, nldj:nlej),(/ ni*nj /)),   & 
    13971424         &                                     latvalue = RESHAPE(plat(nldi:nlei, nldj:nlej),(/ ni*nj /)))   
    1398  
     1425      ! 
    13991426      IF ( ln_mskland ) THEN 
    14001427         ! mask land points, keep values on coast line -> specific mask for U, V and W points 
     
    14091436         CALL iom_set_grid_attr  ( "grid_"//cdgrd//"_3D", mask = RESHAPE(zmask(nldi:nlei,nldj:nlej,:),(/ni,nj,jpk/)) /= 0. ) 
    14101437      ENDIF 
    1411        
     1438      ! 
    14121439   END SUBROUTINE set_grid 
    14131440 
     
    14201447      !! 
    14211448      !!---------------------------------------------------------------------- 
    1422       CHARACTER(LEN=1) , INTENT(in) :: cdgrd 
    1423       ! 
    1424       REAL(wp), DIMENSION(jpi,jpj), INTENT(in)           :: plon_cnr, plat_cnr  ! Lat/lon coordinates of a contiguous vertex of cell (i,j) 
    1425       REAL(wp), DIMENSION(jpi,jpj), OPTIONAL, INTENT(in) :: plon_pnt, plat_pnt  ! Lat/lon coordinates of the point of cell (i,j) 
    1426       ! 
    1427       REAL(wp), ALLOCATABLE, DIMENSION(:,:,:,:)   :: z_bnds      ! Lat/lon coordinates of the vertices of cell (i,j) 
    1428       REAL(wp), ALLOCATABLE, DIMENSION(:,:)       :: z_fld       ! Working array to determine where to rotate cells 
    1429       REAL(wp), ALLOCATABLE, DIMENSION(:,:)       :: z_rot       ! Lat/lon working array for rotation of cells 
    1430       ! 
    1431       INTEGER :: icnr, jcnr                                      ! Offset such that the vertex coordinate (i+icnr,j+jcnr) 
    1432       !                                                          ! represents the bottom-left corner of cell (i,j) 
     1449      CHARACTER(LEN=1)                      , INTENT(in) :: cdgrd 
     1450      REAL(wp), DIMENSION(jpi,jpj)          , INTENT(in) :: plon_cnr, plat_cnr  ! Lat/lon coord. of a contiguous vertex of cell (i,j) 
     1451      REAL(wp), DIMENSION(jpi,jpj), OPTIONAL, INTENT(in) :: plon_pnt, plat_pnt  ! Lat/lon coord. of the point of cell (i,j) 
     1452      ! 
    14331453      INTEGER :: ji, jj, jn, ni, nj 
    1434  
     1454      INTEGER :: icnr, jcnr                                    ! Offset such that the vertex coordinate (i+icnr,j+jcnr) 
     1455      !                                                        ! represents the bottom-left corner of cell (i,j) 
     1456      REAL(wp), ALLOCATABLE, DIMENSION(:,:,:,:) :: z_bnds      ! Lat/lon coordinates of the vertices of cell (i,j) 
     1457      REAL(wp), ALLOCATABLE, DIMENSION(:,:)     :: z_fld       ! Working array to determine where to rotate cells 
     1458      REAL(wp), ALLOCATABLE, DIMENSION(:,:)     :: z_rot       ! Lat/lon working array for rotation of cells 
     1459      !!---------------------------------------------------------------------- 
     1460      ! 
    14351461      ALLOCATE( z_bnds(4,jpi,jpj,2), z_fld(jpi,jpj), z_rot(4,2)  ) 
    1436  
     1462      ! 
    14371463      ! Offset of coordinate representing bottom-left corner 
    14381464      SELECT CASE ( TRIM(cdgrd) ) 
    1439          CASE ('T', 'W') 
    1440             icnr = -1 ; jcnr = -1 
    1441          CASE ('U') 
    1442             icnr =  0 ; jcnr = -1 
    1443          CASE ('V') 
    1444             icnr = -1 ; jcnr =  0 
     1465      CASE ('T', 'W')   ;   icnr = -1   ;   jcnr = -1 
     1466      CASE ('U')        ;   icnr =  0   ;   jcnr = -1 
     1467      CASE ('V')        ;   icnr = -1   ;   jcnr =  0 
    14451468      END SELECT 
    1446  
     1469      ! 
    14471470      ni = nlei-nldi+1 ; nj = nlej-nldj+1  ! Dimensions of subdomain interior 
    1448  
     1471      ! 
    14491472      z_fld(:,:) = 1._wp 
    14501473      CALL lbc_lnk( z_fld, cdgrd, -1. )    ! Working array for location of northfold 
    1451  
     1474      ! 
    14521475      ! Cell vertices that can be defined 
    14531476      DO jj = 2, jpjm1 
     
    14631486         END DO 
    14641487      END DO 
    1465  
     1488      ! 
    14661489      ! Cell vertices on boundries 
    14671490      DO jn = 1, 4 
     
    14691492         CALL lbc_lnk( z_bnds(jn,:,:,2), cdgrd, 1., pval=999._wp ) 
    14701493      END DO 
    1471  
     1494      ! 
    14721495      ! Zero-size cells at closed boundaries if cell points provided, 
    14731496      ! otherwise they are closed cells with unrealistic bounds 
     
    14941517         ENDIF 
    14951518      ENDIF 
    1496  
    1497       ! Rotate cells at the north fold 
    1498       IF( (nbondj == 1 .OR. nbondj == 2) .AND. jperio >= 3 ) THEN 
     1519      ! 
     1520      IF( (nbondj == 1 .OR. nbondj == 2) .AND. jperio >= 3 ) THEN    ! Rotate cells at the north fold 
    14991521         DO jj = 1, jpj 
    15001522            DO ji = 1, jpi 
     
    15061528            END DO 
    15071529         END DO 
    1508  
    1509       ! Invert cells at the symmetric equator 
    1510       ELSE IF( nbondj == 2 .AND. jperio == 2 ) THEN 
     1530      ELSE IF( nbondj == 2 .AND. jperio == 2 ) THEN                  ! Invert cells at the symmetric equator 
    15111531         DO ji = 1, jpi 
    15121532            z_rot(1:2,:) = z_bnds(3:4,ji,1,:) 
     
    15151535         END DO 
    15161536      ENDIF 
    1517  
     1537      ! 
    15181538      CALL iom_set_domain_attr("grid_"//cdgrd, bounds_lat = RESHAPE(z_bnds(:,nldi:nlei,nldj:nlej,1),(/ 4,ni*nj /)),           & 
    1519                                                bounds_lon = RESHAPE(z_bnds(:,nldi:nlei,nldj:nlej,2),(/ 4,ni*nj /)), nvertex=4 ) 
    1520  
     1539          &                                    bounds_lon = RESHAPE(z_bnds(:,nldi:nlei,nldj:nlej,2),(/ 4,ni*nj /)), nvertex=4 ) 
     1540      ! 
    15211541      DEALLOCATE( z_bnds, z_fld, z_rot )  
    1522  
     1542      ! 
    15231543   END SUBROUTINE set_grid_bounds 
    15241544 
     
    15351555      REAL(wp), DIMENSION(:), ALLOCATABLE  ::   zlon 
    15361556      INTEGER  :: ni,nj, ix, iy 
    1537  
    1538        
     1557      !!---------------------------------------------------------------------- 
     1558      ! 
    15391559      ni=nlei-nldi+1 ; nj=nlej-nldj+1            ! define zonal mean domain (jpj*jpk) 
    15401560      ALLOCATE( zlon(ni*nj) )       ;       zlon(:) = 0. 
    1541  
    1542       CALL dom_ngb( 180., 90., ix, iy, 'T' ) !  i-line that passes near the North Pole : Reference latitude (used in plots) 
     1561      ! 
     1562      CALL dom_ngb( -168.53, 65.03, ix, iy, 'T' ) !  i-line that passes through Bering Strait: Reference latitude (used in plots) 
     1563!      CALL dom_ngb( 180., 90., ix, iy, 'T' ) !  i-line that passes near the North Pole : Reference latitude (used in plots) 
    15431564      CALL iom_set_domain_attr("gznl", ni_glo=jpiglo, nj_glo=jpjglo, ibegin=nimpp+nldi-2, jbegin=njmpp+nldj-2, ni=ni, nj=nj) 
    15441565      CALL iom_set_domain_attr("gznl", data_dim=2, data_ibegin = 1-nldi, data_ni = jpi, data_jbegin = 1-nldj, data_nj = jpj) 
     
    15511572   END SUBROUTINE set_grid_znl 
    15521573 
     1574 
    15531575   SUBROUTINE set_scalar 
    15541576      !!---------------------------------------------------------------------- 
     
    15601582      REAL(wp), DIMENSION(1)   ::   zz = 1. 
    15611583      !!---------------------------------------------------------------------- 
    1562  
     1584      ! 
    15631585      CALL iom_set_domain_attr('scalarpoint', ni_glo=jpnij, nj_glo=1, ibegin=narea-1, jbegin=0, ni=1, nj=1) 
    15641586      CALL iom_set_domain_attr('scalarpoint', data_dim=2, data_ibegin = 1, data_ni = 1, data_jbegin = 1, data_nj = 1) 
    1565        
    1566       zz=REAL(narea,wp) 
     1587      ! 
     1588      zz = REAL( narea, wp ) 
    15671589      CALL iom_set_domain_attr('scalarpoint', lonvalue=zz, latvalue=zz) 
    1568  
     1590      ! 
    15691591   END SUBROUTINE set_scalar 
    15701592 
     
    16371659      zlatpira = (/ -19.0, -14.0,  -8.0, 0.0, 4.0, 8.0, 12.0, 15.0, 20.0 /) 
    16381660      CALL set_mooring( zlonpira, zlatpira ) 
    1639  
    1640        
     1661      ! 
    16411662   END SUBROUTINE set_xmlatt 
    16421663 
    16431664 
    1644    SUBROUTINE set_mooring( plon, plat) 
     1665   SUBROUTINE set_mooring( plon, plat ) 
    16451666      !!---------------------------------------------------------------------- 
    16461667      !!                     ***  ROUTINE set_mooring  *** 
     
    16491670      !! 
    16501671      !!---------------------------------------------------------------------- 
    1651       REAL(wp), DIMENSION(:), INTENT(in) ::  plon, plat           ! longitudes/latitudes oft the mooring 
     1672      REAL(wp), DIMENSION(:), INTENT(in) ::   plon, plat   ! longitudes/latitudes oft the mooring 
    16521673      ! 
    16531674!!$      CHARACTER(len=1),DIMENSION(4) ::   clgrd = (/ 'T', 'U', 'V', 'W' /)   ! suffix name 
     
    17981819               idx = INDEX(clname,'@enddate@') + INDEX(clname,'@ENDDATE@') 
    17991820            END DO 
    1800  
     1821            ! 
    18011822            idx = INDEX(clname,'@enddatefull@') + INDEX(clname,'@ENDDATEFULL@') 
    18021823            DO WHILE ( idx /= 0 )  
     
    18051826               idx = INDEX(clname,'@enddatefull@') + INDEX(clname,'@ENDDATEFULL@') 
    18061827            END DO 
    1807  
     1828            ! 
    18081829            IF( jn == 1 .AND. TRIM(Agrif_CFixed()) /= '0' )   clname = TRIM(Agrif_CFixed())//"_"//TRIM(clname) 
    18091830            IF( jn == 1 )   CALL iom_set_file_attr( cdid, name        = clname ) 
    18101831            IF( jn == 2 )   CALL iom_set_file_attr( cdid, name_suffix = clname ) 
    1811  
    1812          ENDIF 
    1813  
     1832            ! 
     1833         ENDIF 
     1834         ! 
    18141835      END DO 
    1815  
     1836      ! 
    18161837   END SUBROUTINE iom_update_file_name 
    18171838 
     
    18221843      !! 
    18231844      !! ** Purpose :   send back the date corresponding to the given julian day 
    1824       !! 
    18251845      !!---------------------------------------------------------------------- 
    18261846      REAL(wp), INTENT(in   )           ::   pjday         ! julian day 
     
    18331853      REAL(wp)          ::   zsec 
    18341854      LOGICAL           ::   ll24, llfull 
     1855      !!---------------------------------------------------------------------- 
    18351856      ! 
    18361857      IF( PRESENT(ld24) ) THEN   ;   ll24 = ld24 
    18371858      ELSE                       ;   ll24 = .FALSE. 
    18381859      ENDIF 
    1839  
     1860      ! 
    18401861      IF( PRESENT(ldfull) ) THEN   ;   llfull = ldfull 
    18411862      ELSE                         ;   llfull = .FALSE. 
    18421863      ENDIF 
    1843  
     1864      ! 
    18441865      CALL ju2ymds( pjday, iyear, imonth, iday, zsec ) 
    18451866      isec = NINT(zsec) 
    1846  
     1867      ! 
    18471868      IF ( ll24 .AND. isec == 0 ) THEN   ! 00:00 of the next day -> move to 24:00 of the current day 
    18481869         CALL ju2ymds( pjday - 1., iyear, imonth, iday, zsec ) 
    18491870         isec = 86400 
    18501871      ENDIF 
    1851  
     1872      ! 
    18521873      IF( iyear < 10000 ) THEN   ;   clfmt = "i4.4,2i2.2"                ! format used to write the date  
    18531874      ELSE                       ;   WRITE(clfmt, "('i',i1,',2i2.2')") INT(LOG10(REAL(iyear,wp))) + 1 
    18541875      ENDIF 
    1855        
     1876      ! 
    18561877!$AGRIF_DO_NOT_TREAT       
    1857 ! Should be fixed in the conv 
     1878      ! needed in the conv 
    18581879      IF( llfull ) THEN  
    18591880         clfmt = TRIM(clfmt)//",'_',i2.2,':',i2.2,':',i2.2" 
     
    18671888      ENDIF 
    18681889!$AGRIF_END_DO_NOT_TREAT       
    1869  
     1890      ! 
    18701891   END FUNCTION iom_sdate 
    18711892 
    18721893#else 
    1873  
    18741894 
    18751895   SUBROUTINE iom_setkt( kt, cdname ) 
Note: See TracChangeset for help on using the changeset viewer.