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 8882 for branches/2017/dev_CNRS_2017/NEMOGCM/NEMO/OPA_SRC/IOM – NEMO

Ignore:
Timestamp:
2017-12-01T18:44:09+01:00 (7 years ago)
Author:
flavoni
Message:

dev_CNRS_2017 branch: merged dev_r7881_ENHANCE09_RK3 with trunk r8864

Location:
branches/2017/dev_CNRS_2017/NEMOGCM/NEMO/OPA_SRC/IOM
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • branches/2017/dev_CNRS_2017/NEMOGCM/NEMO/OPA_SRC/IOM/in_out_manager.F90

    r7646 r8882  
    8888   INTEGER ::   nitrst                !: time step at which restart file should be written 
    8989   LOGICAL ::   lrst_oce              !: logical to control the oce restart write  
     90   LOGICAL ::   lrst_ice              !: logical to control the ice restart write  
    9091   INTEGER ::   numror = 0            !: logical unit for ocean restart (read). Init to 0 is needed for SAS (in daymod.F90) 
     92   INTEGER ::   numrir                !: logical unit for ice   restart (read) 
    9193   INTEGER ::   numrow                !: logical unit for ocean restart (write) 
     94   INTEGER ::   numriw                !: logical unit for ice   restart (write) 
    9295   INTEGER ::   nrst_lst              !: number of restart to output next 
    9396 
     
    9699   !!---------------------------------------------------------------------- 
    97100   LOGICAL ::   ln_ctl           !: run control for debugging 
     101   LOGICAL ::   ln_timing        !: run control for timing 
     102!!gm to be removed at the end of the 2017 merge party 
    98103   INTEGER ::   nn_timing        !: run control for timing 
    99    INTEGER ::   nn_diacfl        !: flag whether to create CFL diagnostics 
     104!!gm end 
     105   LOGICAL ::   ln_diacfl        !: flag whether to create CFL diagnostics 
    100106   INTEGER ::   nn_print         !: level of print (0 no print) 
    101107   INTEGER ::   nn_ictls         !: Start i indice for the SUM control 
     
    126132   INTEGER ::   numoni          =   -1      !: logical unit for Output Namelist Ice 
    127133   INTEGER ::   numevo_ice      =   -1      !: logical unit for ice variables (temp. evolution) 
    128    INTEGER ::   numsol          =   -1      !: logical unit for solver statistics 
     134   INTEGER ::   numrun          =   -1      !: logical unit for run statistics 
    129135   INTEGER ::   numdct_in       =   -1      !: logical unit for transports computing 
    130136   INTEGER ::   numdct_vol      =   -1      !: logical unit for voulume transports output 
  • branches/2017/dev_CNRS_2017/NEMOGCM/NEMO/OPA_SRC/IOM/iom.F90

    r8698 r8882  
    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 #elif defined key_lim2 
    37    USE par_ice_2 
     36   USE ice      , ONLY :   jpl 
    3837#endif 
    3938   USE domngb          ! ocean space and time domain 
     
    8281 
    8382   !!---------------------------------------------------------------------- 
    84    !! NEMO/OPA 3.3 , NEMO Consortium (2010) 
     83   !! NEMO/OPA 4.0 , NEMO Consortium (2017) 
    8584   !! $Id$ 
    8685   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt) 
    8786   !!---------------------------------------------------------------------- 
    88  
    8987CONTAINS 
    9088 
     
    9795      !!---------------------------------------------------------------------- 
    9896      CHARACTER(len=*), INTENT(in)  :: cdname 
     97      ! 
    9998#if defined key_iomput 
    100  
     99      ! 
    101100      TYPE(xios_duration) :: dtime    = xios_duration(0, 0, 0, 0, 0, 0) 
    102101      TYPE(xios_date)     :: start_date 
     
    106105      REAL(wp), ALLOCATABLE, DIMENSION(:,:) :: zt_bnds, zw_bnds 
    107106      !!---------------------------------------------------------------------- 
    108  
     107      ! 
    109108      ALLOCATE( zt_bnds(2,jpk), zw_bnds(2,jpk) ) 
    110  
     109      ! 
    111110      clname = cdname 
    112111      IF( TRIM(Agrif_CFixed()) /= '0' )   clname = TRIM(Agrif_CFixed())//"_"//TRIM(cdname) 
     
    127126      ! horizontal grid definition 
    128127      CALL set_scalar 
    129  
     128      ! 
    130129      IF( TRIM(cdname) == TRIM(cxios_context) ) THEN   
    131130         CALL set_grid( "T", glamt, gphit )  
     
    146145         ENDIF 
    147146      ENDIF 
    148  
     147      ! 
    149148      IF( TRIM(cdname) == TRIM(cxios_context)//"_crs" ) THEN   
    150149         CALL dom_grid_crs   ! Save the parent grid information  & Switch to coarse grid domain 
     
    169168         ENDIF 
    170169      ENDIF 
    171  
     170      ! 
    172171      ! vertical grid definition 
    173172      CALL iom_set_axis_attr( "deptht", gdept_1d ) 
     
    175174      CALL iom_set_axis_attr( "depthv", gdept_1d ) 
    176175      CALL iom_set_axis_attr( "depthw", gdepw_1d ) 
    177  
     176      ! 
    178177      ! Add vertical grid bounds 
    179178      jkmin = MIN(2,jpk)  ! in case jpk=1 (i.e. sas2D) 
     
    188187      CALL iom_set_axis_attr( "depthv", bounds=zt_bnds ) 
    189188      CALL iom_set_axis_attr( "depthw", bounds=zw_bnds ) 
    190  
    191  
     189      ! 
    192190# if defined key_floats 
    193191      CALL iom_set_axis_attr( "nfloat", (/ (REAL(ji,wp), ji=1,nfloat) /) ) 
    194192# endif 
    195 #if defined key_lim3 || defined key_lim2 
     193# if defined key_lim3 
    196194      CALL iom_set_axis_attr( "ncatice", (/ (REAL(ji,wp), ji=1,jpl) /) ) 
    197 #endif 
     195      ! SIMIP diagnostics (4 main arctic straits) 
     196      CALL iom_set_axis_attr( "nstrait", (/ (REAL(ji,wp), ji=1,4) /) ) 
     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 
    207       CALL xios_set_timestep(dtime) 
     207      CALL xios_set_timestep( dtime ) 
    208208      CALL xios_close_context_definition() 
    209        
    210       CALL xios_update_calendar(0) 
    211  
     209      CALL xios_update_calendar( 0 ) 
     210      ! 
    212211      DEALLOCATE( zt_bnds, zw_bnds ) 
    213  
     212      ! 
    214213#endif 
    215        
     214      ! 
    216215   END SUBROUTINE iom_init 
    217216 
     
    239238 
    240239 
    241    SUBROUTINE iom_open( cdname, kiomid, ldwrt, kdom, kiolib, ldstop, ldiof ) 
     240   SUBROUTINE iom_open( cdname, kiomid, ldwrt, kdom, kiolib, ldstop, ldiof, kdlev ) 
    242241      !!--------------------------------------------------------------------- 
    243242      !!                   ***  SUBROUTINE  iom_open  *** 
     
    252251      LOGICAL         , INTENT(in   ), OPTIONAL ::   ldstop   ! stop if open to read a non-existing file (default = .TRUE.) 
    253252      LOGICAL         , INTENT(in   ), OPTIONAL ::   ldiof    ! Interp On the Fly, needed for AGRIF (default = .FALSE.) 
    254  
     253      INTEGER         , INTENT(in   ), OPTIONAL ::   kdlev    ! number of vertical levels 
     254      ! 
    255255      CHARACTER(LEN=256)    ::   clname    ! the name of the file based on cdname [[+clcpu]+clcpu] 
    256256      CHARACTER(LEN=256)    ::   cltmpn    ! tempory name to store clname (in writting mode) 
     
    405405      IF( istop == nstop ) THEN   ! no error within this routine 
    406406         SELECT CASE (iolib) 
    407          CASE (jpnf90   )   ;   CALL iom_nf90_open(    clname, kiomid, llwrt, llok, idompar ) 
     407         CASE (jpnf90   )   ;   CALL iom_nf90_open(    clname, kiomid, llwrt, llok, idompar, kdlev = kdlev ) 
    408408         CASE DEFAULT 
    409409            CALL ctl_stop( TRIM(clinfo)//' accepted IO library is only jpnf90 (jpioipsl option has been removed) ' ) 
     
    644644      INTEGER , DIMENSION(:)     , INTENT(in   ), OPTIONAL ::   kcount     ! number of points to be read in each axis 
    645645      LOGICAL                    , INTENT(in   ), OPTIONAL ::   lrowattr   ! logical flag telling iom_get to 
    646                                                                            ! look for and use a file attribute 
    647                                                                            ! called open_ocean_jstart to set the start 
    648                                                                            ! value for the 2nd dimension (netcdf only) 
     646      !                                                                    ! look for and use a file attribute 
     647      !                                                                    ! called open_ocean_jstart to set the start 
     648      !                                                                    ! value for the 2nd dimension (netcdf only) 
    649649      ! 
    650650      LOGICAL                        ::   llnoov      ! local definition to read overlap 
     
    672672      CHARACTER(LEN=1)               ::   clrankpv, cldmspc      !  
    673673      LOGICAL                        ::   ll_depth_spec ! T => if kstart, kcount present then *only* use values for 3rd spatial dimension. 
     674      INTEGER                        ::   inlev       ! number of levels for 3D data 
    674675      !--------------------------------------------------------------------- 
    675676      ! 
     677      inlev = -1 
     678      IF( PRESENT(pv_r3d) )   inlev = SIZE(pv_r3d, 3) 
    676679      clname = iom_file(kiomid)%name   !   esier to read 
    677680      clinfo = '          iom_get_123d, file: '//trim(clname)//', var: '//trim(cdvar) 
     
    775778 
    776779         IF( PRESENT(kstart) .AND. .NOT. ll_depth_spec ) THEN  
    777             istart(1:idmspc) = kstart(1:idmspc) ; icnt(1:idmspc) = kcount(1:idmspc) 
     780            istart(1:idmspc) = kstart(1:idmspc)  
     781            icnt  (1:idmspc) = kcount(1:idmspc) 
    778782         ELSE 
    779783            IF(idom == jpdom_unknown ) THEN 
     
    801805                  ENDIF 
    802806                  IF( PRESENT(pv_r3d) ) THEN 
    803                      IF( idom == jpdom_data ) THEN                                  ; icnt(3) = jpkglo 
    804                      ELSE IF( ll_depth_spec .AND. PRESENT(kstart) ) THEN            ; istart(3) = kstart(3); icnt(3) = kcount(3) 
    805                      ELSE                                                           ; icnt(3) = jpk 
     807                     IF( idom == jpdom_data ) THEN                        ;                               icnt(3) = inlev 
     808                     ELSEIF( ll_depth_spec .AND. PRESENT(kstart) ) THEN   ;   istart(3) = kstart(3)   ;  icnt(3) = kcount(3) 
     809                     ELSE                                                 ;                               icnt(3) = inlev 
    806810                     ENDIF 
    807811                  ENDIF 
     
    886890            ELSEIF( PRESENT(pv_r3d) .AND. idom /= jpdom_unknown ) THEN 
    887891               ! this if could be simplified with the new lbc_lnk that works with any size of the 3rd dimension 
    888                IF( icnt(3) == jpk ) THEN 
     892               IF( icnt(3) == inlev ) THEN 
    889893                  CALL lbc_lnk( pv_r3d,'Z',-999.,'no0' ) 
    890894               ELSE   ! put some arbitrary value (a call to lbc_lnk will be done later...) 
     
    11351139   END SUBROUTINE iom_rp0d 
    11361140 
     1141 
    11371142   SUBROUTINE iom_rp1d( kt, kwrite, kiomid, cdvar, pvar, ktype ) 
    11381143      INTEGER         , INTENT(in)                         ::   kt       ! ocean time-step 
     
    11551160   END SUBROUTINE iom_rp1d 
    11561161 
     1162 
    11571163   SUBROUTINE iom_rp2d( kt, kwrite, kiomid, cdvar, pvar, ktype ) 
    11581164      INTEGER         , INTENT(in)                         ::   kt       ! ocean time-step 
     
    11751181   END SUBROUTINE iom_rp2d 
    11761182 
     1183 
    11771184   SUBROUTINE iom_rp3d( kt, kwrite, kiomid, cdvar, pvar, ktype ) 
    11781185      INTEGER         , INTENT(in)                         ::   kt       ! ocean time-step 
     
    12361243      REAL(wp),       DIMENSION(:,:,:), INTENT(in) ::   pfield3d 
    12371244#if defined key_iomput 
    1238       CALL xios_send_field(cdname, pfield3d) 
     1245      CALL xios_send_field( cdname, pfield3d ) 
    12391246#else 
    12401247      IF( .FALSE. )   WRITE(numout,*) cdname, pfield3d   ! useless test to avoid compilation warnings 
    12411248#endif 
    12421249   END SUBROUTINE iom_p3d 
     1250 
     1251#if defined key_iomput 
    12431252   !!---------------------------------------------------------------------- 
    1244  
    1245 #if defined key_iomput 
     1253   !!   'key_iomput'                                         IOM  interface 
     1254   !!---------------------------------------------------------------------- 
    12461255 
    12471256   SUBROUTINE iom_set_domain_attr( cdid, ni_glo, nj_glo, ibegin, jbegin, ni, nj, zoom_ibegin, zoom_jbegin, zoom_ni, zoom_nj,   & 
    12481257      &                                    data_dim, data_ibegin, data_ni, data_jbegin, data_nj, lonvalue, latvalue, mask,     & 
    12491258      &                                    nvertex, bounds_lon, bounds_lat, area ) 
    1250       CHARACTER(LEN=*)                   , INTENT(in) ::   cdid 
    1251       INTEGER                  , OPTIONAL, INTENT(in) ::   ni_glo, nj_glo, ibegin, jbegin, ni, nj 
    1252       INTEGER                  , OPTIONAL, INTENT(in) ::   data_dim, data_ibegin, data_ni, data_jbegin, data_nj 
    1253       INTEGER                  , OPTIONAL, INTENT(in) ::   zoom_ibegin, zoom_jbegin, zoom_ni, zoom_nj, nvertex 
    1254       REAL(wp), DIMENSION(:)   , OPTIONAL, INTENT(in) ::   lonvalue, latvalue 
    1255       REAL(wp), DIMENSION(:,:) , OPTIONAL, INTENT(in) ::   bounds_lon, bounds_lat, area 
    1256       LOGICAL, DIMENSION(:)   , OPTIONAL, INTENT(in) ::   mask 
    1257  
    1258  
    1259       IF ( xios_is_valid_domain     (cdid) ) THEN 
     1259      !!---------------------------------------------------------------------- 
     1260      !!---------------------------------------------------------------------- 
     1261      CHARACTER(LEN=*)                  , INTENT(in) ::   cdid 
     1262      INTEGER                 , OPTIONAL, INTENT(in) ::   ni_glo, nj_glo, ibegin, jbegin, ni, nj 
     1263      INTEGER                 , OPTIONAL, INTENT(in) ::   data_dim, data_ibegin, data_ni, data_jbegin, data_nj 
     1264      INTEGER                 , OPTIONAL, INTENT(in) ::   zoom_ibegin, zoom_jbegin, zoom_ni, zoom_nj, nvertex 
     1265      REAL(wp), DIMENSION(:)  , OPTIONAL, INTENT(in) ::   lonvalue, latvalue 
     1266      REAL(wp), DIMENSION(:,:), OPTIONAL, INTENT(in) ::   bounds_lon, bounds_lat, area 
     1267      LOGICAL , DIMENSION(:)  , OPTIONAL, INTENT(in) ::   mask 
     1268      !!---------------------------------------------------------------------- 
     1269      ! 
     1270      IF( xios_is_valid_domain     (cdid) ) THEN 
    12601271         CALL xios_set_domain_attr     ( cdid, ni_glo=ni_glo, nj_glo=nj_glo, ibegin=ibegin, jbegin=jbegin, ni=ni, nj=nj,   & 
    12611272            &    data_dim=data_dim, data_ibegin=data_ibegin, data_ni=data_ni, data_jbegin=data_jbegin, data_nj=data_nj ,   & 
     
    12631274            &    bounds_lat_1D=bounds_lat, area=area, type='curvilinear') 
    12641275     ENDIF 
    1265       IF ( xios_is_valid_domaingroup(cdid) ) THEN 
     1276      IF( xios_is_valid_domaingroup(cdid) ) THEN 
    12661277         CALL xios_set_domaingroup_attr( cdid, ni_glo=ni_glo, nj_glo=nj_glo, ibegin=ibegin, jbegin=jbegin, ni=ni, nj=nj,   & 
    12671278            &    data_dim=data_dim, data_ibegin=data_ibegin, data_ni=data_ni, data_jbegin=data_jbegin, data_nj=data_nj ,   & 
     
    12691280            &    bounds_lat_1D=bounds_lat, area=area, type='curvilinear' ) 
    12701281      ENDIF 
    1271  
     1282      ! 
    12721283      CALL xios_solve_inheritance() 
    1273  
     1284      ! 
    12741285   END SUBROUTINE iom_set_domain_attr 
    12751286 
    12761287 
    1277    SUBROUTINE iom_set_zoom_domain_attr( cdid, ibegin, jbegin, ni, nj) 
    1278       CHARACTER(LEN=*)                   , INTENT(in) ::   cdid 
    1279       INTEGER                  , OPTIONAL, INTENT(in) ::   ibegin, jbegin, ni, nj 
    1280  
    1281       IF ( xios_is_valid_zoom_domain     (cdid) ) THEN 
    1282           CALL xios_set_zoom_domain_attr     ( cdid, ibegin=ibegin, jbegin=jbegin, ni=ni,    & 
    1283             &   nj=nj) 
    1284      ENDIF 
     1288   SUBROUTINE iom_set_zoom_domain_attr( cdid, ibegin, jbegin, ni, nj ) 
     1289      !!---------------------------------------------------------------------- 
     1290      !!---------------------------------------------------------------------- 
     1291      CHARACTER(LEN=*)          , INTENT(in) ::   cdid 
     1292      INTEGER         , OPTIONAL, INTENT(in) ::   ibegin, jbegin, ni, nj 
     1293      !!---------------------------------------------------------------------- 
     1294      IF( xios_is_valid_zoom_domain(cdid) )   CALL xios_set_zoom_domain_attr( cdid, ibegin=ibegin, jbegin=jbegin, ni=ni, nj=nj ) 
    12851295   END SUBROUTINE iom_set_zoom_domain_attr 
    12861296 
    12871297 
    12881298   SUBROUTINE iom_set_axis_attr( cdid, paxis, bounds ) 
     1299      !!---------------------------------------------------------------------- 
     1300      !!---------------------------------------------------------------------- 
    12891301      CHARACTER(LEN=*)      , INTENT(in) ::   cdid 
    12901302      REAL(wp), DIMENSION(:)  , OPTIONAL, INTENT(in) ::   paxis 
    12911303      REAL(wp), DIMENSION(:,:), OPTIONAL, INTENT(in) ::   bounds 
    1292  
    1293       IF ( PRESENT(paxis) ) THEN 
    1294          IF ( xios_is_valid_axis     (cdid) )   CALL xios_set_axis_attr     ( cdid, n_glo=SIZE(paxis), value=paxis ) 
    1295          IF ( xios_is_valid_axisgroup(cdid) )   CALL xios_set_axisgroup_attr( cdid, n_glo=SIZE(paxis), value=paxis ) 
    1296       ENDIF 
    1297       IF ( xios_is_valid_axis     (cdid) )   CALL xios_set_axis_attr     ( cdid, bounds=bounds ) 
    1298       IF ( xios_is_valid_axisgroup(cdid) )   CALL xios_set_axisgroup_attr( cdid, bounds=bounds ) 
     1304      !!---------------------------------------------------------------------- 
     1305      IF( PRESENT(paxis) ) THEN 
     1306         IF( xios_is_valid_axis     (cdid) )   CALL xios_set_axis_attr     ( cdid, n_glo=SIZE(paxis), value=paxis ) 
     1307         IF( xios_is_valid_axisgroup(cdid) )   CALL xios_set_axisgroup_attr( cdid, n_glo=SIZE(paxis), value=paxis ) 
     1308      ENDIF 
     1309      IF( xios_is_valid_axis     (cdid) )   CALL xios_set_axis_attr     ( cdid, bounds=bounds ) 
     1310      IF( xios_is_valid_axisgroup(cdid) )   CALL xios_set_axisgroup_attr( cdid, bounds=bounds ) 
    12991311      CALL xios_solve_inheritance() 
    13001312   END SUBROUTINE iom_set_axis_attr 
     
    13021314 
    13031315   SUBROUTINE iom_set_field_attr( cdid, freq_op, freq_offset ) 
    1304       CHARACTER(LEN=*)          , INTENT(in) ::   cdid 
    1305       TYPE(xios_duration),OPTIONAL , INTENT(in) ::   freq_op 
    1306       TYPE(xios_duration),OPTIONAL , INTENT(in) ::   freq_offset 
    1307       IF ( xios_is_valid_field     (cdid) )   CALL xios_set_field_attr       & 
    1308     &     ( cdid, freq_op=freq_op, freq_offset=freq_offset ) 
    1309       IF ( xios_is_valid_fieldgroup(cdid) )   CALL xios_set_fieldgroup_attr  & 
    1310     &                    ( cdid, freq_op=freq_op, freq_offset=freq_offset ) 
     1316      !!---------------------------------------------------------------------- 
     1317      !!---------------------------------------------------------------------- 
     1318      CHARACTER(LEN=*)             , INTENT(in) ::   cdid 
     1319      TYPE(xios_duration), OPTIONAL, INTENT(in) ::   freq_op 
     1320      TYPE(xios_duration), OPTIONAL, INTENT(in) ::   freq_offset 
     1321      !!---------------------------------------------------------------------- 
     1322      IF( xios_is_valid_field     (cdid) )   CALL xios_set_field_attr     ( cdid, freq_op=freq_op, freq_offset=freq_offset ) 
     1323      IF( xios_is_valid_fieldgroup(cdid) )   CALL xios_set_fieldgroup_attr( cdid, freq_op=freq_op, freq_offset=freq_offset ) 
    13111324      CALL xios_solve_inheritance() 
    13121325   END SUBROUTINE iom_set_field_attr 
     
    13141327 
    13151328   SUBROUTINE iom_set_file_attr( cdid, name, name_suffix ) 
     1329      !!---------------------------------------------------------------------- 
     1330      !!---------------------------------------------------------------------- 
    13161331      CHARACTER(LEN=*)          , INTENT(in) ::   cdid 
    13171332      CHARACTER(LEN=*),OPTIONAL , INTENT(in) ::   name, name_suffix 
    1318       IF ( xios_is_valid_file     (cdid) )   CALL xios_set_file_attr     ( cdid, name=name, name_suffix=name_suffix ) 
    1319       IF ( xios_is_valid_filegroup(cdid) )   CALL xios_set_filegroup_attr( cdid, name=name, name_suffix=name_suffix ) 
     1333      !!---------------------------------------------------------------------- 
     1334      IF( xios_is_valid_file     (cdid) )   CALL xios_set_file_attr     ( cdid, name=name, name_suffix=name_suffix ) 
     1335      IF( xios_is_valid_filegroup(cdid) )   CALL xios_set_filegroup_attr( cdid, name=name, name_suffix=name_suffix ) 
    13201336      CALL xios_solve_inheritance() 
    13211337   END SUBROUTINE iom_set_file_attr 
     
    13231339 
    13241340   SUBROUTINE iom_get_file_attr( cdid, name, name_suffix, output_freq ) 
     1341      !!---------------------------------------------------------------------- 
     1342      !!---------------------------------------------------------------------- 
    13251343      CHARACTER(LEN=*)          , INTENT(in ) ::   cdid 
    13261344      CHARACTER(LEN=*),OPTIONAL , INTENT(out) ::   name, name_suffix 
     
    13311349      IF( PRESENT( name_suffix ) )   name_suffix = '' 
    13321350      IF( PRESENT( output_freq ) )   output_freq = xios_duration(0,0,0,0,0,0) 
    1333       IF ( xios_is_valid_file     (cdid) ) THEN 
     1351      IF( xios_is_valid_file     (cdid) ) THEN 
    13341352         CALL xios_solve_inheritance() 
    13351353         CALL xios_is_defined_file_attr     ( cdid, name = llexist1, name_suffix = llexist2, output_freq = llexist3) 
     
    13381356         IF(llexist3)   CALL xios_get_file_attr     ( cdid, output_freq = output_freq ) 
    13391357      ENDIF 
    1340       IF ( xios_is_valid_filegroup(cdid) ) THEN 
     1358      IF( xios_is_valid_filegroup(cdid) ) THEN 
    13411359         CALL xios_solve_inheritance() 
    13421360         CALL xios_is_defined_filegroup_attr( cdid, name = llexist1, name_suffix = llexist2, output_freq = llexist3) 
     
    13491367 
    13501368   SUBROUTINE iom_set_grid_attr( cdid, mask ) 
     1369      !!---------------------------------------------------------------------- 
     1370      !!---------------------------------------------------------------------- 
    13511371      CHARACTER(LEN=*)                   , INTENT(in) ::   cdid 
    13521372      LOGICAL, DIMENSION(:,:,:), OPTIONAL, INTENT(in) ::   mask 
    1353       IF ( xios_is_valid_grid     (cdid) )   CALL xios_set_grid_attr     ( cdid, mask_3D=mask ) 
    1354       IF ( xios_is_valid_gridgroup(cdid) )   CALL xios_set_gridgroup_attr( cdid, mask_3D=mask ) 
     1373      !!---------------------------------------------------------------------- 
     1374      IF( xios_is_valid_grid     (cdid) )   CALL xios_set_grid_attr     ( cdid, mask_3D=mask ) 
     1375      IF( xios_is_valid_gridgroup(cdid) )   CALL xios_set_gridgroup_attr( cdid, mask_3D=mask ) 
    13551376      CALL xios_solve_inheritance() 
    13561377   END SUBROUTINE iom_set_grid_attr 
    13571378 
    13581379   SUBROUTINE iom_setkt( kt, cdname ) 
     1380      !!---------------------------------------------------------------------- 
     1381      !!---------------------------------------------------------------------- 
    13591382      INTEGER         , INTENT(in) ::   kt  
    13601383      CHARACTER(LEN=*), INTENT(in) ::   cdname 
    1361       !      
     1384      !!---------------------------------------------------------------------- 
    13621385      CALL iom_swap( cdname )   ! swap to cdname context 
    13631386      CALL xios_update_calendar(kt) 
    1364       IF( cdname /= TRIM(cxios_context) ) CALL iom_swap( TRIM(cxios_context) )   ! return back to nemo context 
    1365       ! 
     1387      IF( cdname /= TRIM(cxios_context) )   CALL iom_swap( TRIM(cxios_context) )   ! return back to nemo context 
    13661388   END SUBROUTINE iom_setkt 
    13671389 
    13681390   SUBROUTINE iom_context_finalize( cdname ) 
     1391      !!---------------------------------------------------------------------- 
     1392      !!---------------------------------------------------------------------- 
    13691393      CHARACTER(LEN=*), INTENT(in) :: cdname 
    1370       ! 
     1394      !!---------------------------------------------------------------------- 
    13711395      IF( xios_is_valid_context(cdname) ) THEN 
    13721396         CALL iom_swap( cdname )   ! swap to cdname context 
     
    13741398         IF( cdname /= TRIM(cxios_context) ) CALL iom_swap( TRIM(cxios_context) )   ! return back to nemo context 
    13751399      ENDIF 
    1376       ! 
    13771400   END SUBROUTINE iom_context_finalize 
    13781401 
     
    13831406      !! 
    13841407      !! ** Purpose :   define horizontal grids 
    1385       !! 
    13861408      !!---------------------------------------------------------------------- 
    13871409      CHARACTER(LEN=1)            , INTENT(in) ::   cdgrd 
     
    13891411      REAL(wp), DIMENSION(jpi,jpj), INTENT(in) ::   plat 
    13901412      ! 
     1413      INTEGER  :: ni, nj 
    13911414      REAL(wp), DIMENSION(jpi,jpj,jpk) ::   zmask 
    1392       INTEGER  :: ni,nj 
    1393        
    1394       ni=nlei-nldi+1 ; nj=nlej-nldj+1 
    1395  
     1415      !!---------------------------------------------------------------------- 
     1416      ! 
     1417      ni = nlei-nldi+1 
     1418      nj = nlej-nldj+1 
     1419      ! 
    13961420      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) 
    13971421      CALL iom_set_domain_attr("grid_"//cdgrd, data_dim=2, data_ibegin = 1-nldi, data_ni = jpi, data_jbegin = 1-nldj, data_nj = jpj) 
    13981422      CALL iom_set_domain_attr("grid_"//cdgrd, lonvalue = RESHAPE(plon(nldi:nlei, nldj:nlej),(/ ni*nj /)),   & 
    13991423         &                                     latvalue = RESHAPE(plat(nldi:nlei, nldj:nlej),(/ ni*nj /)))   
    1400  
     1424      ! 
    14011425      IF ( ln_mskland ) THEN 
    14021426         ! mask land points, keep values on coast line -> specific mask for U, V and W points 
     
    14111435         CALL iom_set_grid_attr  ( "grid_"//cdgrd//"_3D", mask = RESHAPE(zmask(nldi:nlei,nldj:nlej,:),(/ni,nj,jpk/)) /= 0. ) 
    14121436      ENDIF 
    1413        
     1437      ! 
    14141438   END SUBROUTINE set_grid 
    14151439 
     
    14221446      !! 
    14231447      !!---------------------------------------------------------------------- 
    1424       CHARACTER(LEN=1) , INTENT(in) :: cdgrd 
    1425       ! 
    1426       REAL(wp), DIMENSION(jpi,jpj), INTENT(in)           :: plon_cnr, plat_cnr  ! Lat/lon coordinates of a contiguous vertex of cell (i,j) 
    1427       REAL(wp), DIMENSION(jpi,jpj), OPTIONAL, INTENT(in) :: plon_pnt, plat_pnt  ! Lat/lon coordinates of the point of cell (i,j) 
    1428       ! 
    1429       REAL(wp), ALLOCATABLE, DIMENSION(:,:,:,:)   :: z_bnds      ! Lat/lon coordinates of the vertices of cell (i,j) 
    1430       REAL(wp), ALLOCATABLE, DIMENSION(:,:)       :: z_fld       ! Working array to determine where to rotate cells 
    1431       REAL(wp), ALLOCATABLE, DIMENSION(:,:)       :: z_rot       ! Lat/lon working array for rotation of cells 
    1432       ! 
    1433       INTEGER :: icnr, jcnr                                      ! Offset such that the vertex coordinate (i+icnr,j+jcnr) 
    1434       !                                                          ! represents the bottom-left corner of cell (i,j) 
     1448      CHARACTER(LEN=1)                      , INTENT(in) :: cdgrd 
     1449      REAL(wp), DIMENSION(jpi,jpj)          , INTENT(in) :: plon_cnr, plat_cnr  ! Lat/lon coord. of a contiguous vertex of cell (i,j) 
     1450      REAL(wp), DIMENSION(jpi,jpj), OPTIONAL, INTENT(in) :: plon_pnt, plat_pnt  ! Lat/lon coord. of the point of cell (i,j) 
     1451      ! 
    14351452      INTEGER :: ji, jj, jn, ni, nj 
    1436  
     1453      INTEGER :: icnr, jcnr                                    ! Offset such that the vertex coordinate (i+icnr,j+jcnr) 
     1454      !                                                        ! represents the bottom-left corner of cell (i,j) 
     1455      REAL(wp), ALLOCATABLE, DIMENSION(:,:,:,:) :: z_bnds      ! Lat/lon coordinates of the vertices of cell (i,j) 
     1456      REAL(wp), ALLOCATABLE, DIMENSION(:,:)     :: z_fld       ! Working array to determine where to rotate cells 
     1457      REAL(wp), ALLOCATABLE, DIMENSION(:,:)     :: z_rot       ! Lat/lon working array for rotation of cells 
     1458      !!---------------------------------------------------------------------- 
     1459      ! 
    14371460      ALLOCATE( z_bnds(4,jpi,jpj,2), z_fld(jpi,jpj), z_rot(4,2)  ) 
    1438  
     1461      ! 
    14391462      ! Offset of coordinate representing bottom-left corner 
    14401463      SELECT CASE ( TRIM(cdgrd) ) 
    1441          CASE ('T', 'W') 
    1442             icnr = -1 ; jcnr = -1 
    1443          CASE ('U') 
    1444             icnr =  0 ; jcnr = -1 
    1445          CASE ('V') 
    1446             icnr = -1 ; jcnr =  0 
     1464      CASE ('T', 'W')   ;   icnr = -1   ;   jcnr = -1 
     1465      CASE ('U')        ;   icnr =  0   ;   jcnr = -1 
     1466      CASE ('V')        ;   icnr = -1   ;   jcnr =  0 
    14471467      END SELECT 
    1448  
    1449       ni = nlei-nldi+1 ; nj = nlej-nldj+1  ! Dimensions of subdomain interior 
    1450  
     1468      ! 
     1469      ni = nlei-nldi+1   ! Dimensions of subdomain interior 
     1470      nj = nlej-nldj+1 
     1471      ! 
    14511472      z_fld(:,:) = 1._wp 
    14521473      CALL lbc_lnk( z_fld, cdgrd, -1. )    ! Working array for location of northfold 
    1453  
     1474      ! 
    14541475      ! Cell vertices that can be defined 
    14551476      DO jj = 2, jpjm1 
     
    14651486         END DO 
    14661487      END DO 
    1467  
     1488      ! 
    14681489      ! Cell vertices on boundries 
    14691490      DO jn = 1, 4 
     
    14711492         CALL lbc_lnk( z_bnds(jn,:,:,2), cdgrd, 1., pval=999._wp ) 
    14721493      END DO 
    1473  
     1494      ! 
    14741495      ! Zero-size cells at closed boundaries if cell points provided, 
    14751496      ! otherwise they are closed cells with unrealistic bounds 
     
    14961517         ENDIF 
    14971518      ENDIF 
    1498  
    1499       ! Rotate cells at the north fold 
    1500       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 
    15011521         DO jj = 1, jpj 
    15021522            DO ji = 1, jpi 
     
    15081528            END DO 
    15091529         END DO 
    1510  
    1511       ! Invert cells at the symmetric equator 
    1512       ELSE IF( nbondj == 2 .AND. jperio == 2 ) THEN 
     1530      ELSE IF( nbondj == 2 .AND. jperio == 2 ) THEN                  ! Invert cells at the symmetric equator 
    15131531         DO ji = 1, jpi 
    15141532            z_rot(1:2,:) = z_bnds(3:4,ji,1,:) 
     
    15171535         END DO 
    15181536      ENDIF 
    1519  
     1537      ! 
    15201538      CALL iom_set_domain_attr("grid_"//cdgrd, bounds_lat = RESHAPE(z_bnds(:,nldi:nlei,nldj:nlej,1),(/ 4,ni*nj /)),           & 
    1521                                                bounds_lon = RESHAPE(z_bnds(:,nldi:nlei,nldj:nlej,2),(/ 4,ni*nj /)), nvertex=4 ) 
    1522  
     1539          &                                    bounds_lon = RESHAPE(z_bnds(:,nldi:nlei,nldj:nlej,2),(/ 4,ni*nj /)), nvertex=4 ) 
     1540      ! 
    15231541      DEALLOCATE( z_bnds, z_fld, z_rot )  
    1524  
     1542      ! 
    15251543   END SUBROUTINE set_grid_bounds 
    15261544 
     
    15351553      REAL(wp), DIMENSION(jpi,jpj), INTENT(in) ::   plat 
    15361554      ! 
     1555      INTEGER  :: ni, nj, ix, iy 
    15371556      REAL(wp), DIMENSION(:), ALLOCATABLE  ::   zlon 
    1538       INTEGER  :: ni,nj, ix, iy 
    1539  
    1540        
    1541       ni=nlei-nldi+1 ; nj=nlej-nldj+1            ! define zonal mean domain (jpj*jpk) 
    1542       ALLOCATE( zlon(ni*nj) )       ;       zlon(:) = 0. 
    1543  
     1557      !!---------------------------------------------------------------------- 
     1558      ! 
     1559      ni=nlei-nldi+1       ! define zonal mean domain (jpj*jpk) 
     1560      nj=nlej-nldj+1 
     1561      ALLOCATE( zlon(ni*nj) )       ;       zlon(:) = 0._wp 
     1562      ! 
    15441563      CALL dom_ngb( -168.53, 65.03, ix, iy, 'T' ) !  i-line that passes through Bering Strait: Reference latitude (used in plots) 
     1564!      CALL dom_ngb( 180., 90., ix, iy, 'T' ) !  i-line that passes near the North Pole : Reference latitude (used in plots) 
    15451565      CALL iom_set_domain_attr("gznl", ni_glo=jpiglo, nj_glo=jpjglo, ibegin=nimpp+nldi-2, jbegin=njmpp+nldj-2, ni=ni, nj=nj) 
    15461566      CALL iom_set_domain_attr("gznl", data_dim=2, data_ibegin = 1-nldi, data_ni = jpi, data_jbegin = 1-nldj, data_nj = jpj) 
     
    15531573   END SUBROUTINE set_grid_znl 
    15541574 
     1575 
    15551576   SUBROUTINE set_scalar 
    15561577      !!---------------------------------------------------------------------- 
     
    15621583      REAL(wp), DIMENSION(1)   ::   zz = 1. 
    15631584      !!---------------------------------------------------------------------- 
    1564  
     1585      ! 
    15651586      CALL iom_set_domain_attr('scalarpoint', ni_glo=jpnij, nj_glo=1, ibegin=narea-1, jbegin=0, ni=1, nj=1) 
    15661587      CALL iom_set_domain_attr('scalarpoint', data_dim=2, data_ibegin = 1, data_ni = 1, data_jbegin = 1, data_nj = 1) 
    1567        
    1568       zz=REAL(narea,wp) 
     1588      ! 
     1589      zz = REAL( narea, wp ) 
    15691590      CALL iom_set_domain_attr('scalarpoint', lonvalue=zz, latvalue=zz) 
    1570  
     1591      ! 
    15711592   END SUBROUTINE set_scalar 
    15721593 
     
    15961617      !  
    15971618      ! frequency of the call of iom_put (attribut: freq_op) 
    1598       f_op%timestep = 1        ;  f_of%timestep = 0  ; CALL iom_set_field_attr('field_definition', freq_op=f_op, freq_offset=f_of) 
    1599       f_op%timestep = 2        ;  f_of%timestep = 0  ; CALL iom_set_field_attr('trendT_even'     , freq_op=f_op, freq_offset=f_of) 
    1600       f_op%timestep = 2        ;  f_of%timestep = -1 ; CALL iom_set_field_attr('trendT_odd'      , freq_op=f_op, freq_offset=f_of) 
    1601       f_op%timestep = nn_fsbc  ;  f_of%timestep = 0  ; CALL iom_set_field_attr('SBC'             , freq_op=f_op, freq_offset=f_of) 
    1602       f_op%timestep = nn_fsbc  ;  f_of%timestep = 0  ; CALL iom_set_field_attr('SBC_scalar'      , freq_op=f_op, freq_offset=f_of) 
    1603       f_op%timestep = nn_dttrc ;  f_of%timestep = 0  ; CALL iom_set_field_attr('ptrc_T'          , freq_op=f_op, freq_offset=f_of) 
    1604       f_op%timestep = nn_dttrc ;  f_of%timestep = 0  ; CALL iom_set_field_attr('diad_T'          , freq_op=f_op, freq_offset=f_of) 
     1619      f_op%timestep = 1        ;  f_of%timestep =  0  ; CALL iom_set_field_attr('field_definition', freq_op=f_op, freq_offset=f_of) 
     1620      f_op%timestep = 2        ;  f_of%timestep =  0  ; CALL iom_set_field_attr('trendT_even'     , freq_op=f_op, freq_offset=f_of) 
     1621      f_op%timestep = 2        ;  f_of%timestep = -1  ; CALL iom_set_field_attr('trendT_odd'      , freq_op=f_op, freq_offset=f_of) 
     1622      f_op%timestep = nn_fsbc  ;  f_of%timestep =  0  ; CALL iom_set_field_attr('SBC'             , freq_op=f_op, freq_offset=f_of) 
     1623      f_op%timestep = nn_fsbc  ;  f_of%timestep =  0  ; CALL iom_set_field_attr('SBC_scalar'      , freq_op=f_op, freq_offset=f_of) 
     1624      f_op%timestep = nn_dttrc ;  f_of%timestep =  0  ; CALL iom_set_field_attr('ptrc_T'          , freq_op=f_op, freq_offset=f_of) 
     1625      f_op%timestep = nn_dttrc ;  f_of%timestep =  0  ; CALL iom_set_field_attr('diad_T'          , freq_op=f_op, freq_offset=f_of) 
    16051626 
    16061627      ! output file names (attribut: name) 
     
    16411662      zlatpira = (/ -19.0, -14.0,  -8.0, 0.0, 4.0, 8.0, 12.0, 15.0, 20.0 /) 
    16421663      CALL set_mooring( zlonpira, zlatpira ) 
    1643  
    1644        
     1664      ! 
    16451665   END SUBROUTINE set_xmlatt 
    16461666 
    16471667 
    1648    SUBROUTINE set_mooring( plon, plat) 
     1668   SUBROUTINE set_mooring( plon, plat ) 
    16491669      !!---------------------------------------------------------------------- 
    16501670      !!                     ***  ROUTINE set_mooring  *** 
     
    16531673      !! 
    16541674      !!---------------------------------------------------------------------- 
    1655       REAL(wp), DIMENSION(:), INTENT(in) ::  plon, plat           ! longitudes/latitudes oft the mooring 
     1675      REAL(wp), DIMENSION(:), INTENT(in) ::   plon, plat   ! longitudes/latitudes oft the mooring 
    16561676      ! 
    16571677!!$      CHARACTER(len=1),DIMENSION(4) ::   clgrd = (/ 'T', 'U', 'V', 'W' /)   ! suffix name 
     
    17361756      TYPE(xios_duration)   ::   output_freq  
    17371757      !!---------------------------------------------------------------------- 
    1738  
    1739       DO jn = 1,2 
    1740  
     1758      ! 
     1759      DO jn = 1, 2 
     1760         ! 
    17411761         output_freq = xios_duration(0,0,0,0,0,0) 
    17421762         IF( jn == 1 )   CALL iom_get_file_attr( cdid, name        = clname, output_freq = output_freq ) 
    17431763         IF( jn == 2 )   CALL iom_get_file_attr( cdid, name_suffix = clname ) 
    1744  
     1764         ! 
    17451765         IF ( TRIM(clname) /= '' ) THEN  
    1746  
     1766            ! 
    17471767            idx = INDEX(clname,'@expname@') + INDEX(clname,'@EXPNAME@') 
    17481768            DO WHILE ( idx /= 0 )  
     
    17501770               idx = INDEX(clname,'@expname@') + INDEX(clname,'@EXPNAME@') 
    17511771            END DO 
    1752  
     1772            ! 
    17531773            idx = INDEX(clname,'@freq@') + INDEX(clname,'@FREQ@') 
    17541774            DO WHILE ( idx /= 0 )  
     
    17811801              idx = INDEX(clname,'@freq@') + INDEX(clname,'@FREQ@') 
    17821802            END DO 
    1783  
     1803            ! 
    17841804            idx = INDEX(clname,'@startdate@') + INDEX(clname,'@STARTDATE@') 
    17851805            DO WHILE ( idx /= 0 )  
     
    17881808               idx = INDEX(clname,'@startdate@') + INDEX(clname,'@STARTDATE@') 
    17891809            END DO 
    1790  
     1810            ! 
    17911811            idx = INDEX(clname,'@startdatefull@') + INDEX(clname,'@STARTDATEFULL@') 
    17921812            DO WHILE ( idx /= 0 )  
     
    17951815               idx = INDEX(clname,'@startdatefull@') + INDEX(clname,'@STARTDATEFULL@') 
    17961816            END DO 
    1797  
     1817            ! 
    17981818            idx = INDEX(clname,'@enddate@') + INDEX(clname,'@ENDDATE@') 
    17991819            DO WHILE ( idx /= 0 )  
     
    18021822               idx = INDEX(clname,'@enddate@') + INDEX(clname,'@ENDDATE@') 
    18031823            END DO 
    1804  
     1824            ! 
    18051825            idx = INDEX(clname,'@enddatefull@') + INDEX(clname,'@ENDDATEFULL@') 
    18061826            DO WHILE ( idx /= 0 )  
     
    18091829               idx = INDEX(clname,'@enddatefull@') + INDEX(clname,'@ENDDATEFULL@') 
    18101830            END DO 
    1811  
     1831            ! 
    18121832            IF( jn == 1 .AND. TRIM(Agrif_CFixed()) /= '0' )   clname = TRIM(Agrif_CFixed())//"_"//TRIM(clname) 
    18131833            IF( jn == 1 )   CALL iom_set_file_attr( cdid, name        = clname ) 
    18141834            IF( jn == 2 )   CALL iom_set_file_attr( cdid, name_suffix = clname ) 
    1815  
    1816          ENDIF 
    1817  
     1835            ! 
     1836         ENDIF 
     1837         ! 
    18181838      END DO 
    1819  
     1839      ! 
    18201840   END SUBROUTINE iom_update_file_name 
    18211841 
     
    18261846      !! 
    18271847      !! ** Purpose :   send back the date corresponding to the given julian day 
    1828       !! 
    1829       !!---------------------------------------------------------------------- 
    1830       REAL(wp), INTENT(in   )           ::   pjday         ! julian day 
    1831       LOGICAL , INTENT(in   ), OPTIONAL ::   ld24          ! true to force 24:00 instead of 00:00 
    1832       LOGICAL , INTENT(in   ), OPTIONAL ::   ldfull        ! true to get the compleate date: yyyymmdd_hh:mm:ss 
     1848      !!---------------------------------------------------------------------- 
     1849      REAL(wp), INTENT(in   )           ::   pjday    ! julian day 
     1850      LOGICAL , INTENT(in   ), OPTIONAL ::   ld24     ! true to force 24:00 instead of 00:00 
     1851      LOGICAL , INTENT(in   ), OPTIONAL ::   ldfull   ! true to get the compleate date: yyyymmdd_hh:mm:ss 
    18331852      ! 
    18341853      CHARACTER(LEN=20) ::   iom_sdate 
     
    18371856      REAL(wp)          ::   zsec 
    18381857      LOGICAL           ::   ll24, llfull 
     1858      !!---------------------------------------------------------------------- 
    18391859      ! 
    18401860      IF( PRESENT(ld24) ) THEN   ;   ll24 = ld24 
    18411861      ELSE                       ;   ll24 = .FALSE. 
    18421862      ENDIF 
    1843  
     1863      ! 
    18441864      IF( PRESENT(ldfull) ) THEN   ;   llfull = ldfull 
    18451865      ELSE                         ;   llfull = .FALSE. 
    18461866      ENDIF 
    1847  
     1867      ! 
    18481868      CALL ju2ymds( pjday, iyear, imonth, iday, zsec ) 
    18491869      isec = NINT(zsec) 
    1850  
     1870      ! 
    18511871      IF ( ll24 .AND. isec == 0 ) THEN   ! 00:00 of the next day -> move to 24:00 of the current day 
    18521872         CALL ju2ymds( pjday - 1., iyear, imonth, iday, zsec ) 
    18531873         isec = 86400 
    18541874      ENDIF 
    1855  
     1875      ! 
    18561876      IF( iyear < 10000 ) THEN   ;   clfmt = "i4.4,2i2.2"                ! format used to write the date  
    18571877      ELSE                       ;   WRITE(clfmt, "('i',i1,',2i2.2')") INT(LOG10(REAL(iyear,wp))) + 1 
    18581878      ENDIF 
    1859        
     1879      ! 
    18601880!$AGRIF_DO_NOT_TREAT       
    1861 ! Should be fixed in the conv 
     1881      ! needed in the conv 
    18621882      IF( llfull ) THEN  
    18631883         clfmt = TRIM(clfmt)//",'_',i2.2,':',i2.2,':',i2.2" 
     
    18711891      ENDIF 
    18721892!$AGRIF_END_DO_NOT_TREAT       
    1873  
     1893      ! 
    18741894   END FUNCTION iom_sdate 
    18751895 
    18761896#else 
    1877  
     1897   !!---------------------------------------------------------------------- 
     1898   !!   NOT 'key_iomput'                               a few dummy routines 
     1899   !!---------------------------------------------------------------------- 
    18781900 
    18791901   SUBROUTINE iom_setkt( kt, cdname ) 
     
    18911913 
    18921914   LOGICAL FUNCTION iom_use( cdname ) 
     1915      !!---------------------------------------------------------------------- 
     1916      !!---------------------------------------------------------------------- 
    18931917      CHARACTER(LEN=*), INTENT(in) ::   cdname 
     1918      !!---------------------------------------------------------------------- 
    18941919#if defined key_iomput 
    18951920      iom_use = xios_field_is_active( cdname ) 
  • branches/2017/dev_CNRS_2017/NEMOGCM/NEMO/OPA_SRC/IOM/iom_def.F90

    r7646 r8882  
    11MODULE iom_def 
    2    !!===================================================================== 
     2   !!====================================================================== 
    33   !!                    ***  MODULE  iom_def *** 
    44   !! IOM variables definitions 
    5    !!==================================================================== 
    6    !! History :  9.0  ! 06 09  (S. Masson) Original code 
    7    !!             "   ! 07 07  (D. Storkey) Add uldname 
    8    !!-------------------------------------------------------------------- 
    9    !!--------------------------------------------------------------------------------- 
    10    !! NEMO/OPA 3.3 , NEMO Consortium (2010) 
    11    !! $Id$ 
    12    !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt) 
    13    !!--------------------------------------------------------------------------------- 
    14  
     5   !!====================================================================== 
     6   !! History :  9.0  ! 2006 09  (S. Masson) Original code 
     7   !!             -   ! 2007 07  (D. Storkey) Add uldname 
     8   !!            4.0  ! 2017-11 (M. Andrejczuk) Extend IOM interface to write any 3D fields 
     9   !!---------------------------------------------------------------------- 
    1510   USE par_kind 
    1611 
     
    6459      REAL(kind=wp), DIMENSION(jpmax_vars)      ::   scf      !: scale_factor of the variables 
    6560      REAL(kind=wp), DIMENSION(jpmax_vars)      ::   ofs      !: add_offset of the variables 
     61      INTEGER                                   ::   nlev     ! number of vertical levels 
    6662   END TYPE file_descriptor 
    6763   TYPE(file_descriptor), DIMENSION(jpmax_files), PUBLIC ::   iom_file !: array containing the info for all opened files 
    6864!$AGRIF_END_DO_NOT_TREAT 
    6965 
    70    !!===================================================================== 
     66   !!---------------------------------------------------------------------- 
     67   !! NEMO/OPA 3.3 , NEMO Consortium (2010) 
     68   !! $Id$ 
     69   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt) 
     70   !!====================================================================== 
    7171END MODULE iom_def 
  • branches/2017/dev_CNRS_2017/NEMOGCM/NEMO/OPA_SRC/IOM/iom_nf90.F90

    r7646 r8882  
    11MODULE iom_nf90 
    2    !!===================================================================== 
     2   !!====================================================================== 
    33   !!                    ***  MODULE  iom_nf90 *** 
    44   !! Input/Output manager :  Library to read input files with NF90 (only fliocom module) 
    5    !!==================================================================== 
     5   !!====================================================================== 
    66   !! History :  9.0  ! 05 12  (J. Belier) Original code 
    77   !!            9.0  ! 06 02  (S. Masson) Adaptation to NEMO 
    88   !!             "   ! 07 07  (D. Storkey) Changes to iom_nf90_gettime 
    99   !!            3.6  ! 2015-15  (J. Harle) Added procedure to read REAL attributes 
    10    !!-------------------------------------------------------------------- 
    11    !!gm  caution add !DIR nec: improved performance to be checked as well as no result changes 
    12  
    13    !!-------------------------------------------------------------------- 
     10   !!            4.0  ! 2017-11 (M. Andrejczuk) Extend IOM interface to write any 3D fields 
     11   !!---------------------------------------------------------------------- 
     12 
     13   !!---------------------------------------------------------------------- 
    1414   !!   iom_open       : open a file read only 
    1515   !!   iom_close      : close a file or all files opened by iom 
     
    1818   !!   iom_varid      : get the id of a variable in a file 
    1919   !!   iom_rstput     : write a field in a restart file (interfaced to several routines) 
    20    !!-------------------------------------------------------------------- 
     20   !!---------------------------------------------------------------------- 
    2121   USE dom_oce         ! ocean space and time domain 
    2222   USE lbclnk          ! lateal boundary condition / mpp exchanges 
     
    2929   PRIVATE 
    3030 
    31    PUBLIC iom_nf90_open, iom_nf90_close, iom_nf90_varid, iom_nf90_get, iom_nf90_gettime, iom_nf90_rstput 
     31   PUBLIC iom_nf90_open  , iom_nf90_close, iom_nf90_varid, iom_nf90_get, iom_nf90_gettime, iom_nf90_rstput 
    3232   PUBLIC iom_nf90_getatt, iom_nf90_putatt 
    3333 
     
    4646 
    4747   !!---------------------------------------------------------------------- 
    48    !! NEMO/OPA 3.3 , NEMO Consortium (2010) 
     48   !! NEMO/OPA 4.0 , NEMO Consortium (2017) 
    4949   !! $Id$ 
    5050   !! Software governed by the CeCILL licence (NEMOGCM/NEMO_CeCILL.txt) 
    5151   !!---------------------------------------------------------------------- 
    52  
    5352CONTAINS 
    5453 
    55    SUBROUTINE iom_nf90_open( cdname, kiomid, ldwrt, ldok, kdompar ) 
     54   SUBROUTINE iom_nf90_open( cdname, kiomid, ldwrt, ldok, kdompar, kdlev ) 
    5655      !!--------------------------------------------------------------------- 
    5756      !!                   ***  SUBROUTINE  iom_open  *** 
     
    6463      LOGICAL                , INTENT(in   )           ::   ldok        ! check the existence  
    6564      INTEGER, DIMENSION(2,5), INTENT(in   ), OPTIONAL ::   kdompar     ! domain parameters:  
     65      INTEGER                , INTENT(in   ), OPTIONAL ::   kdlev       ! size of the third dimension 
    6666 
    6767      CHARACTER(LEN=256) ::   clinfo           ! info character 
     
    7676      INTEGER            ::   ihdf5            ! local variable for retrieval of value for NF90_HDF5 
    7777      LOGICAL            ::   llclobber        ! local definition of ln_clobber 
    78       !--------------------------------------------------------------------- 
    79  
     78      INTEGER            ::   ilevels           ! vertical levels 
     79      !--------------------------------------------------------------------- 
     80      ! 
    8081      clinfo = '                    iom_nf90_open ~~~  ' 
    81       istop = nstop   ! store the actual value of nstop 
     82      istop = nstop     ! store the actual value of nstop 
     83      ! 
     84      !                 !number of vertical levels 
     85      IF( PRESENT(kdlev) ) THEN   ;   ilevels = kdlev    ! use input value (useful for sea-ice) 
     86      ELSE                        ;   ilevels = jpk      ! by default jpk 
     87      ENDIF 
     88      ! 
    8289      IF( nn_chunksz > 0 ) THEN   ;   ichunk = nn_chunksz 
    8390      ELSE                        ;   ichunk = NF90_SIZEHINT_DEFAULT 
     
    8592      ! 
    8693      llclobber = ldwrt .AND. ln_clobber 
    87       IF( ldok .AND. .NOT. llclobber ) THEN      ! Open existing file... 
    88          !                 ! ============= 
     94      IF( ldok .AND. .NOT. llclobber ) THEN      !==  Open existing file ==! 
     95         !                                       !=========================! 
    8996         IF( ldwrt ) THEN  ! ... in write mode 
    9097            IF(lwp) WRITE(numout,*) TRIM(clinfo)//' open existing file: '//TRIM(cdname)//' in WRITE mode' 
     
    99106            CALL iom_nf90_check(NF90_OPEN( TRIM(cdname), NF90_NOWRITE, if90id, chunksize = ichunk ), clinfo) 
    100107         ENDIF 
    101       ELSE                                       ! the file does not exist (or we overwrite it) 
    102          !                 ! ============= 
     108      ELSE                                       !== the file doesn't exist ==!  (or we overwrite it) 
     109         !                                       !============================! 
    103110         iln = INDEX( cdname, '.nc' ) 
    104          IF( ldwrt ) THEN  ! the file should be open in write mode so we create it... 
     111         IF( ldwrt ) THEN              !* the file should be open in write mode so we create it... 
    105112            IF( jpnij > 1 ) THEN 
    106113               WRITE(cltmp,'(a,a,i4.4,a)') cdname(1:iln-1), '_', narea-1, '.nc' 
     
    126133            CALL iom_nf90_check(NF90_DEF_DIM( if90id, 'x', kdompar(1,1)  , idmy ), clinfo) 
    127134            CALL iom_nf90_check(NF90_DEF_DIM( if90id, 'y', kdompar(2,1)  , idmy ), clinfo) 
    128             CALL iom_nf90_check(NF90_DEF_DIM( if90id, 'z', jpk           , idmy ), clinfo) 
     135            CALL iom_nf90_check(NF90_DEF_DIM( if90id, 'z', ilevels       , idmy ), clinfo) 
    129136            CALL iom_nf90_check(NF90_DEF_DIM( if90id, 't', NF90_UNLIMITED, idmy ), clinfo) 
    130137            ! global attributes 
     
    139146            CALL iom_nf90_check(NF90_PUT_ATT( if90id, NF90_GLOBAL, 'DOMAIN_halo_size_end'  , kdompar(:,5)       ), clinfo) 
    140147            CALL iom_nf90_check(NF90_PUT_ATT( if90id, NF90_GLOBAL, 'DOMAIN_type'           , 'BOX'              ), clinfo) 
    141          ELSE              ! the file should be open for read mode so it must exist... 
     148         ELSE                          !* the file should be open for read mode so it must exist... 
    142149            CALL ctl_stop( TRIM(clinfo), ' should be impossible case...' ) 
    143150         ENDIF 
    144151      ENDIF 
     152      ! 
    145153      ! start to fill file informations 
    146154      ! ============= 
     
    156164         iom_file(kiomid)%nvars  = 0 
    157165         iom_file(kiomid)%irec   = -1   ! useless for NetCDF files, used to know if the file is in define mode  
     166         iom_file(kiomid)%nlev   = ilevels 
    158167         CALL iom_nf90_check(NF90_Inquire(if90id, unlimitedDimId = iom_file(kiomid)%iduld), clinfo) 
    159          IF ( iom_file(kiomid)%iduld .GE. 0 ) THEN 
    160            CALL iom_nf90_check(NF90_Inquire_Dimension(if90id, iom_file(kiomid)%iduld,     &  
    161         &                                               name = iom_file(kiomid)%uldname,  & 
    162         &                                               len  = iom_file(kiomid)%lenuld ), clinfo ) 
     168         IF( iom_file(kiomid)%iduld .GE. 0 ) THEN 
     169            CALL iom_nf90_check(NF90_Inquire_Dimension(if90id, iom_file(kiomid)%iduld,    &  
     170               &                                       name = iom_file(kiomid)%uldname,   & 
     171               &                                       len  = iom_file(kiomid)%lenuld ), clinfo ) 
    163172         ENDIF 
    164173         IF(lwp) WRITE(numout,*) '                   ---> '//TRIM(cdname)//' OK' 
     
    179188      CHARACTER(LEN=100)  ::   clinfo   ! info character 
    180189      !--------------------------------------------------------------------- 
    181       ! 
    182190      clinfo = '      iom_nf90_close    , file: '//TRIM(iom_file(kiomid)%name) 
    183191      CALL iom_nf90_check(NF90_CLOSE(iom_file(kiomid)%nfid), clinfo) 
    184       !     
    185192   END SUBROUTINE iom_nf90_close 
    186193 
     
    275282      clinfo = 'iom_nf90_g0d , file: '//TRIM(iom_file(kiomid)%name)//', var: '//TRIM(iom_file(kiomid)%cn_var(kvid)) 
    276283      CALL iom_nf90_check(NF90_GET_VAR(iom_file(kiomid)%nfid, iom_file(kiomid)%nvid(kvid), pvar, start = kstart), clinfo ) 
    277       !  
    278284   END SUBROUTINE iom_nf90_g0d 
    279285 
     
    357363         ivarid = NF90_GLOBAL 
    358364      ENDIF 
    359 ! 
     365      ! 
    360366      IF( llok) THEN 
    361367         clinfo = 'iom_nf90_getatt, file: '//TRIM(iom_file(kiomid)%name)//', giatt: '//TRIM(cdatt) 
     
    368374   END SUBROUTINE iom_nf90_giatt 
    369375 
    370    SUBROUTINE iom_nf90_gratt( kiomid, cdatt, pv_r0d, cdvar) 
     376 
     377   SUBROUTINE iom_nf90_gratt( kiomid, cdatt, pv_r0d, cdvar ) 
    371378      !!----------------------------------------------------------------------- 
    372379      !!                  ***  ROUTINE  iom_nf90_gratt  *** 
     
    376383      !!               attribute if optional variable name is supplied (cdvar)) 
    377384      !!----------------------------------------------------------------------- 
    378       INTEGER         , INTENT(in   ) ::   kiomid   ! Identifier of the file 
    379       CHARACTER(len=*), INTENT(in   ) ::   cdatt    ! attribute name 
    380       REAL(wp)        , INTENT(  out) ::   pv_r0d   ! read field 
    381       CHARACTER(len=*), INTENT(in   ), OPTIONAL     & 
    382                       &               ::   cdvar    ! name of the variable 
    383       ! 
    384       INTEGER                         ::   if90id   ! temporary integer 
    385       INTEGER                         ::   ivarid   ! NetCDF variable Id 
    386       LOGICAL                         ::   llok     ! temporary logical 
    387       CHARACTER(LEN=100)              ::   clinfo   ! info character 
     385      INTEGER                   , INTENT(in   ) ::   kiomid   ! Identifier of the file 
     386      CHARACTER(len=*)          , INTENT(in   ) ::   cdatt    ! attribute name 
     387      REAL(wp)                  , INTENT(  out) ::   pv_r0d   ! read field 
     388      CHARACTER(len=*), OPTIONAL, INTENT(in   ) ::   cdvar    ! name of the variable 
     389      ! 
     390      INTEGER            ::   if90id   ! temporary integer 
     391      INTEGER            ::   ivarid   ! NetCDF variable Id 
     392      LOGICAL            ::   llok     ! temporary logical 
     393      CHARACTER(LEN=100) ::   clinfo   ! info character 
    388394      !--------------------------------------------------------------------- 
    389395      ! 
     
    402408         ivarid = NF90_GLOBAL 
    403409      ENDIF 
    404 ! 
     410      ! 
    405411      IF( llok) THEN 
    406412         clinfo = 'iom_nf90_getatt, file: '//TRIM(iom_file(kiomid)%name)//', gratt: '//TRIM(cdatt) 
     
    413419   END SUBROUTINE iom_nf90_gratt 
    414420 
    415    SUBROUTINE iom_nf90_gcatt( kiomid, cdatt, pv_c0d, cdvar) 
     421 
     422   SUBROUTINE iom_nf90_gcatt( kiomid, cdatt, pv_c0d, cdvar ) 
    416423      !!----------------------------------------------------------------------- 
    417424      !!                  ***  ROUTINE  iom_nf90_gcatt  *** 
     
    421428      !!               attribute if optional variable name is supplied (cdvar)) 
    422429      !!----------------------------------------------------------------------- 
    423       INTEGER         , INTENT(in   ) ::   kiomid   ! Identifier of the file 
    424       CHARACTER(len=*), INTENT(in   ) ::   cdatt    ! attribute name 
    425       CHARACTER(len=*), INTENT(  out) ::   pv_c0d   ! read field 
    426       CHARACTER(len=*), INTENT(in   ), OPTIONAL     & 
    427                       &               ::   cdvar    ! name of the variable 
    428       ! 
    429       INTEGER                         ::   if90id   ! temporary integer 
    430       INTEGER                         ::   ivarid   ! NetCDF variable Id 
    431       LOGICAL                         ::   llok     ! temporary logical 
    432       CHARACTER(LEN=100)              ::   clinfo   ! info character 
     430      INTEGER                   , INTENT(in   ) ::   kiomid   ! Identifier of the file 
     431      CHARACTER(len=*)          , INTENT(in   ) ::   cdatt    ! attribute name 
     432      CHARACTER(len=*)          , INTENT(  out) ::   pv_c0d   ! read field 
     433      CHARACTER(len=*), OPTIONAL, INTENT(in   ) ::   cdvar    ! name of the variable 
     434      ! 
     435      INTEGER            ::   if90id   ! temporary integer 
     436      INTEGER            ::   ivarid   ! NetCDF variable Id 
     437      LOGICAL            ::   llok     ! temporary logical 
     438      CHARACTER(LEN=100) ::   clinfo   ! info character 
    433439      !--------------------------------------------------------------------- 
    434440      ! 
     
    458464   END SUBROUTINE iom_nf90_gcatt 
    459465 
     466 
    460467   !!---------------------------------------------------------------------- 
    461468   !!                   INTERFACE iom_nf90_putatt 
     
    495502         ivarid = NF90_GLOBAL 
    496503      ENDIF 
    497 ! 
     504      ! 
    498505      IF( llok) THEN 
    499506         clinfo = 'iom_nf90_putatt, file: '//TRIM(iom_file(kiomid)%name)//', piatt: '//TRIM(cdatt) 
     
    517524   END SUBROUTINE iom_nf90_piatt 
    518525 
    519    SUBROUTINE iom_nf90_pratt( kiomid, cdatt, pv_r0d, cdvar) 
     526 
     527   SUBROUTINE iom_nf90_pratt( kiomid, cdatt, pv_r0d, cdvar ) 
    520528      !!----------------------------------------------------------------------- 
    521529      !!                  ***  ROUTINE  iom_nf90_pratt  *** 
     
    525533      !!               attribute if optional variable name is supplied (cdvar)) 
    526534      !!----------------------------------------------------------------------- 
    527       INTEGER         , INTENT(in   ) ::   kiomid   ! Identifier of the file 
    528       CHARACTER(len=*), INTENT(in   ) ::   cdatt    ! attribute name 
    529       REAL(wp)        , INTENT(in   ) ::   pv_r0d   ! write field 
    530       CHARACTER(len=*), INTENT(in   ), OPTIONAL     & 
    531                       &               ::   cdvar    ! name of the variable 
    532       ! 
    533       INTEGER                         ::   if90id   ! temporary integer 
    534       INTEGER                         ::   ivarid   ! NetCDF variable Id 
    535       LOGICAL                         ::   llok     ! temporary logical 
    536       LOGICAL                         ::   lenddef  ! temporary logical 
    537       CHARACTER(LEN=100)              ::   clinfo   ! info character 
     535      INTEGER                   , INTENT(in   ) ::   kiomid   ! Identifier of the file 
     536      CHARACTER(len=*)          , INTENT(in   ) ::   cdatt    ! attribute name 
     537      REAL(wp)                  , INTENT(in   ) ::   pv_r0d   ! write field 
     538      CHARACTER(len=*), OPTIONAL, INTENT(in   ) ::   cdvar    ! name of the variable 
     539      ! 
     540      INTEGER            ::   if90id   ! temporary integer 
     541      INTEGER            ::   ivarid   ! NetCDF variable Id 
     542      LOGICAL            ::   llok     ! temporary logical 
     543      LOGICAL            ::   lenddef  ! temporary logical 
     544      CHARACTER(LEN=100) ::   clinfo   ! info character 
    538545      !--------------------------------------------------------------------- 
    539546      ! 
     
    550557         ivarid = NF90_GLOBAL 
    551558      ENDIF 
    552 ! 
     559      ! 
    553560      IF( llok) THEN 
    554561         clinfo = 'iom_nf90_putatt, file: '//TRIM(iom_file(kiomid)%name)//', pratt: '//TRIM(cdatt) 
     
    572579   END SUBROUTINE iom_nf90_pratt 
    573580 
    574    SUBROUTINE iom_nf90_pcatt( kiomid, cdatt, pv_c0d, cdvar) 
     581 
     582   SUBROUTINE iom_nf90_pcatt( kiomid, cdatt, pv_c0d, cdvar ) 
    575583      !!----------------------------------------------------------------------- 
    576584      !!                  ***  ROUTINE  iom_nf90_pcatt  *** 
     
    580588      !!               attribute if optional variable name is supplied (cdvar)) 
    581589      !!----------------------------------------------------------------------- 
    582       INTEGER         , INTENT(in   ) ::   kiomid   ! Identifier of the file 
    583       CHARACTER(len=*), INTENT(in   ) ::   cdatt    ! attribute name 
    584       CHARACTER(len=*), INTENT(in   ) ::   pv_c0d   ! write field 
    585       CHARACTER(len=*), INTENT(in   ), OPTIONAL     & 
    586                       &               ::   cdvar    ! name of the variable 
    587       ! 
    588       INTEGER                         ::   if90id   ! temporary integer 
    589       INTEGER                         ::   ivarid   ! NetCDF variable Id 
    590       LOGICAL                         ::   llok     ! temporary logical 
    591       LOGICAL                         ::   lenddef  ! temporary logical 
    592       CHARACTER(LEN=100)              ::   clinfo   ! info character 
     590      INTEGER                   , INTENT(in   ) ::   kiomid   ! Identifier of the file 
     591      CHARACTER(len=*)          , INTENT(in   ) ::   cdatt    ! attribute name 
     592      CHARACTER(len=*)          , INTENT(in   ) ::   pv_c0d   ! write field 
     593      CHARACTER(len=*), OPTIONAL, INTENT(in   ) ::   cdvar    ! name of the variable 
     594      ! 
     595      INTEGER            ::   if90id   ! temporary integer 
     596      INTEGER            ::   ivarid   ! NetCDF variable Id 
     597      LOGICAL            ::   llok     ! temporary logical 
     598      LOGICAL            ::   lenddef  ! temporary logical 
     599      CHARACTER(LEN=100) ::   clinfo   ! info character 
    593600      !--------------------------------------------------------------------- 
    594601      ! 
     
    605612         ivarid = NF90_GLOBAL 
    606613      ENDIF 
    607 ! 
     614      ! 
    608615      IF( llok) THEN 
    609616         clinfo = 'iom_nf90_putatt, file: '//TRIM(iom_file(kiomid)%name)//', pcatt: '//TRIM(cdatt) 
     
    658665 
    659666   SUBROUTINE iom_nf90_rp0123d( kt, kwrite, kiomid, cdvar , kvid  , ktype,   & 
    660          &                               pv_r0d, pv_r1d, pv_r2d, pv_r3d ) 
     667         &                                  pv_r0d, pv_r1d, pv_r2d, pv_r3d ) 
    661668      !!-------------------------------------------------------------------- 
    662669      !!                   ***  SUBROUTINE  iom_nf90_rstput  *** 
     
    687694      INTEGER               :: itype                ! variable type 
    688695      INTEGER, DIMENSION(4) :: ichunksz             ! NetCDF4 chunk sizes. Will be computed using 
    689                                                     ! nn_nchunks_[i,j,k,t] namelist parameters 
    690       INTEGER               :: ichunkalg, ishuffle,& 
    691                                ideflate, ideflate_level 
    692                                                     ! NetCDF4 internally fixed parameters 
     696      !                                             ! nn_nchunks_[i,j,k,t] namelist parameters 
     697      INTEGER               :: ichunkalg, ishuffle, ideflate, ideflate_level 
     698      !                                             ! NetCDF4 internally fixed parameters 
    693699      LOGICAL               :: lchunk               ! logical switch to activate chunking and compression 
    694                                                     ! when appropriate (currently chunking is applied to 4d fields only) 
     700      !                                             ! when appropriate (currently chunking is applied to 4d fields only) 
     701      INTEGER               :: idlv                 ! local variable 
    695702      !--------------------------------------------------------------------- 
    696703      ! 
     
    706713         ENDIF 
    707714         ! define the dimension variables if it is not already done 
    708          cltmp = (/ 'nav_lon     ', 'nav_lat     ', 'nav_lev     ', 'time_counter' /) 
     715         IF(iom_file(kiomid)%nlev == jpk ) THEN 
     716          cltmp = (/ 'nav_lon     ', 'nav_lat     ', 'nav_lev     ', 'time_counter' /) 
     717         ELSE 
     718          cltmp = (/ 'nav_lon     ', 'nav_lat     ', 'numcat      ', 'time_counter' /) 
     719         ENDIF 
    709720         CALL iom_nf90_check(NF90_DEF_VAR( if90id, TRIM(cltmp(1)), NF90_FLOAT , (/ 1, 2 /), iom_file(kiomid)%nvid(1) ), clinfo) 
    710721         CALL iom_nf90_check(NF90_DEF_VAR( if90id, TRIM(cltmp(2)), NF90_FLOAT , (/ 1, 2 /), iom_file(kiomid)%nvid(2) ), clinfo) 
     
    755766         IF( PRESENT(pv_r0d) ) THEN 
    756767            CALL iom_nf90_check(NF90_DEF_VAR( if90id, TRIM(cdvar), itype,                    & 
    757                  &                            iom_file(kiomid)%nvid(idvar) ), clinfo) 
     768               &                              iom_file(kiomid)%nvid(idvar) ), clinfo ) 
    758769         ELSE 
    759770            CALL iom_nf90_check(NF90_DEF_VAR( if90id, TRIM(cdvar), itype, idimid(1:idims),   & 
    760                  &                            iom_file(kiomid)%nvid(idvar) ), clinfo) 
     771               &                              iom_file(kiomid)%nvid(idvar) ), clinfo ) 
    761772         ENDIF 
    762773         lchunk = .false. 
    763          IF( snc4set%luse .AND. idims.eq.4 ) lchunk = .true. 
     774         IF( snc4set%luse .AND. idims == 4 )  lchunk = .true. 
    764775         ! update informations structure related the new variable we want to add... 
    765776         iom_file(kiomid)%nvars         = idvar 
     
    782793            ichunksz(3) = MIN( ichunksz(3),MAX( (ichunksz(3)-1)/snc4set%nk + 1 , 1 ) ) ! Suggested default nc4set%nk=6 
    783794            ichunksz(4) = 1                                                            ! Do not allow chunks to span the 
    784                                                                                        ! unlimited dimension 
     795            !                                                                          ! unlimited dimension 
    785796            CALL iom_nf90_check(SET_NF90_DEF_VAR_CHUNKING(if90id, idvar, ichunkalg, ichunksz), clinfo) 
    786797            CALL iom_nf90_check(SET_NF90_DEF_VAR_DEFLATE(if90id, idvar, ishuffle, ideflate, ideflate_level), clinfo) 
     
    791802         idvar = kvid 
    792803      ENDIF 
    793  
     804      ! 
    794805      ! time step kwrite : write the variable 
    795806      IF( kt == kwrite ) THEN 
     
    815826            ! trick: is defined to 0 => dimension variable are defined but not yet written 
    816827            IF( iom_file(kiomid)%dimsz(1, 1) == 0 ) THEN 
    817                CALL iom_nf90_check(NF90_INQ_VARID( if90id, 'nav_lon'     , idmy ), clinfo) 
    818                CALL iom_nf90_check(NF90_PUT_VAR( if90id, idmy, glamt(ix1:ix2, iy1:iy2) ), clinfo) 
    819                CALL iom_nf90_check(NF90_INQ_VARID( if90id, 'nav_lat'     , idmy ), clinfo) 
    820                CALL iom_nf90_check(NF90_PUT_VAR( if90id, idmy, gphit(ix1:ix2, iy1:iy2) ), clinfo) 
    821                CALL iom_nf90_check(NF90_INQ_VARID( if90id, 'nav_lev'     , idmy ), clinfo) 
    822                CALL iom_nf90_check(NF90_PUT_VAR( if90id, idmy, gdept_1d                ), clinfo) 
     828               CALL iom_nf90_check( NF90_INQ_VARID( if90id, 'nav_lon'     , idmy )         , clinfo ) 
     829               CALL iom_nf90_check( NF90_PUT_VAR  ( if90id, idmy, glamt(ix1:ix2, iy1:iy2) ), clinfo ) 
     830               CALL iom_nf90_check( NF90_INQ_VARID( if90id, 'nav_lat'     , idmy )         , clinfo ) 
     831               CALL iom_nf90_check( NF90_PUT_VAR  ( if90id, idmy, gphit(ix1:ix2, iy1:iy2) ), clinfo ) 
     832               IF(iom_file(kiomid)%nlev == jpk ) THEN  
     833                  !NEMO 
     834                  CALL iom_nf90_check( NF90_INQ_VARID( if90id, 'nav_lev'     , idmy ), clinfo ) 
     835                  CALL iom_nf90_check( NF90_PUT_VAR  ( if90id, idmy, gdept_1d       ), clinfo ) 
     836               ELSE 
     837                  CALL iom_nf90_check( NF90_INQ_VARID( if90id, 'numcat'     , idmy ), clinfo) 
     838                  CALL iom_nf90_check( NF90_PUT_VAR  ( if90id, idmy, (/ (idlv, idlv = 1,iom_file(kiomid)%nlev) /)), clinfo ) 
     839               ENDIF 
    823840               ! +++ WRONG VALUE: to be improved but not really useful... 
    824                CALL iom_nf90_check(NF90_INQ_VARID( if90id, 'time_counter', idmy ), clinfo) 
    825                CALL iom_nf90_check(NF90_PUT_VAR( if90id, idmy, kt                      ), clinfo)    
     841               CALL iom_nf90_check( NF90_INQ_VARID( if90id, 'time_counter', idmy ), clinfo ) 
     842               CALL iom_nf90_check( NF90_PUT_VAR( if90id, idmy, kt                      ), clinfo )    
    826843               ! update the values of the variables dimensions size 
    827                CALL iom_nf90_check(NF90_INQUIRE_DIMENSION( if90id, 1, len = iom_file(kiomid)%dimsz(1,1) ), clinfo) 
    828                CALL iom_nf90_check(NF90_INQUIRE_DIMENSION( if90id, 2, len = iom_file(kiomid)%dimsz(2,1) ), clinfo) 
     844               CALL iom_nf90_check( NF90_INQUIRE_DIMENSION( if90id, 1, len = iom_file(kiomid)%dimsz(1,1) ), clinfo ) 
     845               CALL iom_nf90_check( NF90_INQUIRE_DIMENSION( if90id, 2, len = iom_file(kiomid)%dimsz(2,1) ), clinfo ) 
    829846               iom_file(kiomid)%dimsz(1:2, 2) = iom_file(kiomid)%dimsz(1:2, 1) 
    830                CALL iom_nf90_check(NF90_INQUIRE_DIMENSION( if90id, 3, len = iom_file(kiomid)%dimsz(1,3) ), clinfo) 
     847               CALL iom_nf90_check( NF90_INQUIRE_DIMENSION( if90id, 3, len = iom_file(kiomid)%dimsz(1,3) ), clinfo ) 
    831848               iom_file(kiomid)%dimsz(1  , 4) = 1   ! unlimited dimension 
    832849               IF(lwp) WRITE(numout,*) TRIM(clinfo)//' write dimension variables done' 
     
    837854         ! ============= 
    838855         IF(     PRESENT(pv_r0d) ) THEN 
    839             CALL iom_nf90_check(NF90_PUT_VAR( if90id, idvar, pv_r0d                      ), clinfo) 
     856            CALL iom_nf90_check( NF90_PUT_VAR( if90id, idvar, pv_r0d                    ), clinfo ) 
    840857         ELSEIF( PRESENT(pv_r1d) ) THEN 
    841             CALL iom_nf90_check(NF90_PUT_VAR( if90id, idvar, pv_r1d(                  :) ), clinfo) 
     858            CALL iom_nf90_check( NF90_PUT_VAR( if90id, idvar, pv_r1d(:)                 ), clinfo ) 
    842859         ELSEIF( PRESENT(pv_r2d) ) THEN 
    843             CALL iom_nf90_check(NF90_PUT_VAR( if90id, idvar, pv_r2d(ix1:ix2, iy1:iy2   ) ), clinfo) 
     860            CALL iom_nf90_check( NF90_PUT_VAR( if90id, idvar, pv_r2d(ix1:ix2,iy1:iy2)   ), clinfo ) 
    844861         ELSEIF( PRESENT(pv_r3d) ) THEN 
    845             CALL iom_nf90_check(NF90_PUT_VAR( if90id, idvar, pv_r3d(ix1:ix2, iy1:iy2, :) ), clinfo) 
     862            CALL iom_nf90_check( NF90_PUT_VAR( if90id, idvar, pv_r3d(ix1:ix2,iy1:iy2,:) ), clinfo ) 
    846863         ENDIF 
    847864         ! add 1 to the size of the temporal dimension (not really useful...) 
Note: See TracChangeset for help on using the changeset viewer.