Index: NEMO/branches/2020/dev_12905_xios_restart/src/ICE/icedia.F90
===================================================================
--- NEMO/branches/2020/dev_12905_xios_restart/src/ICE/icedia.F90	(revision 13931)
+++ NEMO/branches/2020/dev_12905_xios_restart/src/ICE/icedia.F90	(revision 13932)
@@ -221,18 +221,16 @@
          IF( ln_rstart ) THEN                   !* Read the restart file
             !
-            IF(lrxios) CALL iom_swap(cr_icerst_cxt)
-            CALL iom_get( numrir, 'kt_ice' , ziter, ldxios = lrxios )
+            CALL iom_get( numrir, 'kt_ice' , ziter )
             IF(lwp) WRITE(numout,*)
             IF(lwp) WRITE(numout,*) 'ice_dia_rst read at time step = ', ziter
             IF(lwp) WRITE(numout,*) '~~~~~~~~~~'
-            CALL iom_get( numrir, 'frc_voltop' , frc_voltop, ldxios = lrxios  )
-            CALL iom_get( numrir, 'frc_volbot' , frc_volbot, ldxios = lrxios  )
-            CALL iom_get( numrir, 'frc_temtop' , frc_temtop, ldxios = lrxios  )
-            CALL iom_get( numrir, 'frc_tembot' , frc_tembot, ldxios = lrxios  )
-            CALL iom_get( numrir, 'frc_sal'    , frc_sal,    ldxios = lrxios  )
-            CALL iom_get( numrir, jpdom_auto, 'vol_loc_ini', vol_loc_ini, ldxios = lrxios )
-            CALL iom_get( numrir, jpdom_auto, 'tem_loc_ini', tem_loc_ini, ldxios = lrxios )
-            CALL iom_get( numrir, jpdom_auto, 'sal_loc_ini', sal_loc_ini, ldxios = lrxios )
-            IF(lrxios) CALL iom_swap(cxios_context)
+            CALL iom_get( numrir, 'frc_voltop' , frc_voltop  )
+            CALL iom_get( numrir, 'frc_volbot' , frc_volbot  )
+            CALL iom_get( numrir, 'frc_temtop' , frc_temtop  )
+            CALL iom_get( numrir, 'frc_tembot' , frc_tembot  )
+            CALL iom_get( numrir, 'frc_sal'    , frc_sal     )
+            CALL iom_get( numrir, jpdom_auto, 'vol_loc_ini', vol_loc_ini )
+            CALL iom_get( numrir, jpdom_auto, 'tem_loc_ini', tem_loc_ini )
+            CALL iom_get( numrir, jpdom_auto, 'sal_loc_ini', sal_loc_ini )
          ELSE
             IF(lwp) WRITE(numout,*)
@@ -263,14 +261,12 @@
          ! Write in numriw (if iter == nitrst)
          ! ------------------ 
-         IF( lwxios ) CALL iom_swap(      cw_icerst_cxt         )
-         CALL iom_rstput( iter, nitrst, numriw, 'frc_voltop' , frc_voltop,  ldxios = lwxios )
-         CALL iom_rstput( iter, nitrst, numriw, 'frc_volbot' , frc_volbot,  ldxios = lwxios )
-         CALL iom_rstput( iter, nitrst, numriw, 'frc_temtop' , frc_temtop,  ldxios = lwxios )
-         CALL iom_rstput( iter, nitrst, numriw, 'frc_tembot' , frc_tembot,  ldxios = lwxios )
-         CALL iom_rstput( iter, nitrst, numriw, 'frc_sal'    , frc_sal,     ldxios = lwxios )
-         CALL iom_rstput( iter, nitrst, numriw, 'vol_loc_ini', vol_loc_ini, ldxios = lwxios )
-         CALL iom_rstput( iter, nitrst, numriw, 'tem_loc_ini', tem_loc_ini, ldxios = lwxios )
-         CALL iom_rstput( iter, nitrst, numriw, 'sal_loc_ini', sal_loc_ini, ldxios = lwxios )
-         IF( lwxios ) CALL iom_swap(      cxios_context         )
+         CALL iom_rstput( iter, nitrst, numriw, 'frc_voltop' , frc_voltop )
+         CALL iom_rstput( iter, nitrst, numriw, 'frc_volbot' , frc_volbot )
+         CALL iom_rstput( iter, nitrst, numriw, 'frc_temtop' , frc_temtop )
+         CALL iom_rstput( iter, nitrst, numriw, 'frc_tembot' , frc_tembot )
+         CALL iom_rstput( iter, nitrst, numriw, 'frc_sal'    , frc_sal    )
+         CALL iom_rstput( iter, nitrst, numriw, 'vol_loc_ini', vol_loc_ini )
+         CALL iom_rstput( iter, nitrst, numriw, 'tem_loc_ini', tem_loc_ini )
+         CALL iom_rstput( iter, nitrst, numriw, 'sal_loc_ini', sal_loc_ini )
          !
       ENDIF
Index: NEMO/branches/2020/dev_12905_xios_restart/src/ICE/icedyn_adv_pra.F90
===================================================================
--- NEMO/branches/2020/dev_12905_xios_restart/src/ICE/icedyn_adv_pra.F90	(revision 13931)
+++ NEMO/branches/2020/dev_12905_xios_restart/src/ICE/icedyn_adv_pra.F90	(revision 13932)
@@ -955,49 +955,48 @@
          !
          IF( id1 > 0 ) THEN                     !**  Read the restart file  **!
-            IF(lrxios) CALL iom_swap(cr_icerst_cxt)
             !
             !                                                        ! ice thickness
-            CALL iom_get( numrir, jpdom_auto, 'sxice' , sxice , psgn = -1._wp, ldxios = lrxios )
-            CALL iom_get( numrir, jpdom_auto, 'syice' , syice , psgn = -1._wp, ldxios = lrxios )
-            CALL iom_get( numrir, jpdom_auto, 'sxxice', sxxice, ldxios = lrxios )
-            CALL iom_get( numrir, jpdom_auto, 'syyice', syyice, ldxios = lrxios )
-            CALL iom_get( numrir, jpdom_auto, 'sxyice', sxyice, ldxios = lrxios )
+            CALL iom_get( numrir, jpdom_auto, 'sxice' , sxice , psgn = -1._wp )
+            CALL iom_get( numrir, jpdom_auto, 'syice' , syice , psgn = -1._wp )
+            CALL iom_get( numrir, jpdom_auto, 'sxxice', sxxice )
+            CALL iom_get( numrir, jpdom_auto, 'syyice', syyice )
+            CALL iom_get( numrir, jpdom_auto, 'sxyice', sxyice )
             !                                                        ! snow thickness
-            CALL iom_get( numrir, jpdom_auto, 'sxsn'  , sxsn  , psgn = -1._wp, ldxios = lrxios )
-            CALL iom_get( numrir, jpdom_auto, 'sysn'  , sysn  , psgn = -1._wp, ldxios = lrxios )
-            CALL iom_get( numrir, jpdom_auto, 'sxxsn' , sxxsn, ldxios = lrxios  )
-            CALL iom_get( numrir, jpdom_auto, 'syysn' , syysn, ldxios = lrxios  )
-            CALL iom_get( numrir, jpdom_auto, 'sxysn' , sxysn, ldxios = lrxios  )
+            CALL iom_get( numrir, jpdom_auto, 'sxsn'  , sxsn  , psgn = -1._wp )
+            CALL iom_get( numrir, jpdom_auto, 'sysn'  , sysn  , psgn = -1._wp )
+            CALL iom_get( numrir, jpdom_auto, 'sxxsn' , sxxsn  )
+            CALL iom_get( numrir, jpdom_auto, 'syysn' , syysn  )
+            CALL iom_get( numrir, jpdom_auto, 'sxysn' , sxysn  )
             !                                                        ! ice concentration
-            CALL iom_get( numrir, jpdom_auto, 'sxa'   , sxa   , psgn = -1._wp, ldxios = lrxios )
-            CALL iom_get( numrir, jpdom_auto, 'sya'   , sya   , psgn = -1._wp, ldxios = lrxios )
-            CALL iom_get( numrir, jpdom_auto, 'sxxa'  , sxxa, ldxios = lrxios   )
-            CALL iom_get( numrir, jpdom_auto, 'syya'  , syya, ldxios = lrxios   )
-            CALL iom_get( numrir, jpdom_auto, 'sxya'  , sxya, ldxios = lrxios   )
+            CALL iom_get( numrir, jpdom_auto, 'sxa'   , sxa   , psgn = -1._wp )
+            CALL iom_get( numrir, jpdom_auto, 'sya'   , sya   , psgn = -1._wp )
+            CALL iom_get( numrir, jpdom_auto, 'sxxa'  , sxxa   )
+            CALL iom_get( numrir, jpdom_auto, 'syya'  , syya   )
+            CALL iom_get( numrir, jpdom_auto, 'sxya'  , sxya   )
             !                                                        ! ice salinity
-            CALL iom_get( numrir, jpdom_auto, 'sxsal' , sxsal , psgn = -1._wp, ldxios = lrxios )
-            CALL iom_get( numrir, jpdom_auto, 'sysal' , sysal , psgn = -1._wp, ldxios = lrxios )
-            CALL iom_get( numrir, jpdom_auto, 'sxxsal', sxxsal, ldxios = lrxios )
-            CALL iom_get( numrir, jpdom_auto, 'syysal', syysal, ldxios = lrxios )
-            CALL iom_get( numrir, jpdom_auto, 'sxysal', sxysal, ldxios = lrxios )
+            CALL iom_get( numrir, jpdom_auto, 'sxsal' , sxsal , psgn = -1._wp )
+            CALL iom_get( numrir, jpdom_auto, 'sysal' , sysal , psgn = -1._wp )
+            CALL iom_get( numrir, jpdom_auto, 'sxxsal', sxxsal )
+            CALL iom_get( numrir, jpdom_auto, 'syysal', syysal )
+            CALL iom_get( numrir, jpdom_auto, 'sxysal', sxysal )
             !                                                        ! ice age
-            CALL iom_get( numrir, jpdom_auto, 'sxage' , sxage , psgn = -1._wp, ldxios = lrxios )
-            CALL iom_get( numrir, jpdom_auto, 'syage' , syage , psgn = -1._wp, ldxios = lrxios )
-            CALL iom_get( numrir, jpdom_auto, 'sxxage', sxxage, ldxios = lrxios )
-            CALL iom_get( numrir, jpdom_auto, 'syyage', syyage, ldxios = lrxios )
-            CALL iom_get( numrir, jpdom_auto, 'sxyage', sxyage, ldxios = lrxios )
+            CALL iom_get( numrir, jpdom_auto, 'sxage' , sxage , psgn = -1._wp )
+            CALL iom_get( numrir, jpdom_auto, 'syage' , syage , psgn = -1._wp )
+            CALL iom_get( numrir, jpdom_auto, 'sxxage', sxxage )
+            CALL iom_get( numrir, jpdom_auto, 'syyage', syyage )
+            CALL iom_get( numrir, jpdom_auto, 'sxyage', sxyage )
             !                                                        ! snow layers heat content
             DO jk = 1, nlay_s
                WRITE(zchar1,'(I2.2)') jk
                znam = 'sxc0'//'_l'//zchar1  
-               CALL iom_get( numrir, jpdom_auto, znam , z3d, psgn = -1._wp, ldxios = lrxios )   ;   sxc0 (:,:,jk,:) = z3d(:,:,:)
+               CALL iom_get( numrir, jpdom_auto, znam , z3d, psgn = -1._wp )   ;   sxc0 (:,:,jk,:) = z3d(:,:,:)
                znam = 'syc0'//'_l'//zchar1  
-               CALL iom_get( numrir, jpdom_auto, znam , z3d, psgn = -1._wp, ldxios = lrxios )   ;   syc0 (:,:,jk,:) = z3d(:,:,:)
+               CALL iom_get( numrir, jpdom_auto, znam , z3d, psgn = -1._wp )   ;   syc0 (:,:,jk,:) = z3d(:,:,:)
                znam = 'sxxc0'//'_l'//zchar1 
-               CALL iom_get( numrir, jpdom_auto, znam , z3d, ldxios = lrxios )   ;   sxxc0(:,:,jk,:) = z3d(:,:,:)
+               CALL iom_get( numrir, jpdom_auto, znam , z3d )   ;   sxxc0(:,:,jk,:) = z3d(:,:,:)
                znam = 'syyc0'//'_l'//zchar1 
-               CALL iom_get( numrir, jpdom_auto, znam , z3d, ldxios = lrxios )   ;   syyc0(:,:,jk,:) = z3d(:,:,:)
+               CALL iom_get( numrir, jpdom_auto, znam , z3d )   ;   syyc0(:,:,jk,:) = z3d(:,:,:)
                znam = 'sxyc0'//'_l'//zchar1 
-               CALL iom_get( numrir, jpdom_auto, znam , z3d, ldxios = lrxios )   ;   sxyc0(:,:,jk,:) = z3d(:,:,:)
+               CALL iom_get( numrir, jpdom_auto, znam , z3d )   ;   sxyc0(:,:,jk,:) = z3d(:,:,:)
             END DO
             !                                                        ! ice layers heat content
@@ -1005,28 +1004,28 @@
                WRITE(zchar1,'(I2.2)') jk
                znam = 'sxe'//'_l'//zchar1   
-               CALL iom_get( numrir, jpdom_auto, znam , z3d, psgn = -1._wp, ldxios = lrxios )   ;   sxe (:,:,jk,:) = z3d(:,:,:)
+               CALL iom_get( numrir, jpdom_auto, znam , z3d, psgn = -1._wp )   ;   sxe (:,:,jk,:) = z3d(:,:,:)
                znam = 'sye'//'_l'//zchar1   
-               CALL iom_get( numrir, jpdom_auto, znam , z3d, psgn = -1._wp, ldxios = lrxios )   ;   sye (:,:,jk,:) = z3d(:,:,:)
+               CALL iom_get( numrir, jpdom_auto, znam , z3d, psgn = -1._wp )   ;   sye (:,:,jk,:) = z3d(:,:,:)
                znam = 'sxxe'//'_l'//zchar1  
-               CALL iom_get( numrir, jpdom_auto, znam , z3d, ldxios = lrxios )   ;   sxxe(:,:,jk,:) = z3d(:,:,:)
+               CALL iom_get( numrir, jpdom_auto, znam , z3d )   ;   sxxe(:,:,jk,:) = z3d(:,:,:)
                znam = 'syye'//'_l'//zchar1  
-               CALL iom_get( numrir, jpdom_auto, znam , z3d, ldxios = lrxios )   ;   syye(:,:,jk,:) = z3d(:,:,:)
+               CALL iom_get( numrir, jpdom_auto, znam , z3d )   ;   syye(:,:,jk,:) = z3d(:,:,:)
                znam = 'sxye'//'_l'//zchar1  
-               CALL iom_get( numrir, jpdom_auto, znam , z3d, ldxios = lrxios )   ;   sxye(:,:,jk,:) = z3d(:,:,:)
+               CALL iom_get( numrir, jpdom_auto, znam , z3d )   ;   sxye(:,:,jk,:) = z3d(:,:,:)
             END DO
             !
             IF( ln_pnd_LEV ) THEN                                    ! melt pond fraction
                IF( iom_varid( numrir, 'sxap', ldstop = .FALSE. ) > 0 ) THEN
-                  CALL iom_get( numrir, jpdom_auto, 'sxap' , sxap , psgn = -1._wp, ldxios = lrxios )
-                  CALL iom_get( numrir, jpdom_auto, 'syap' , syap , psgn = -1._wp, ldxios = lrxios )
-                  CALL iom_get( numrir, jpdom_auto, 'sxxap', sxxap, ldxios = lrxios )
-                  CALL iom_get( numrir, jpdom_auto, 'syyap', syyap, ldxios = lrxios )
-                  CALL iom_get( numrir, jpdom_auto, 'sxyap', sxyap, ldxios = lrxios )
+                  CALL iom_get( numrir, jpdom_auto, 'sxap' , sxap , psgn = -1._wp )
+                  CALL iom_get( numrir, jpdom_auto, 'syap' , syap , psgn = -1._wp )
+                  CALL iom_get( numrir, jpdom_auto, 'sxxap', sxxap )
+                  CALL iom_get( numrir, jpdom_auto, 'syyap', syyap )
+                  CALL iom_get( numrir, jpdom_auto, 'sxyap', sxyap )
                   !                                                     ! melt pond volume
-                  CALL iom_get( numrir, jpdom_auto, 'sxvp' , sxvp , psgn = -1._wp, ldxios = lrxios )
-                  CALL iom_get( numrir, jpdom_auto, 'syvp' , syvp , psgn = -1._wp, ldxios = lrxios )
-                  CALL iom_get( numrir, jpdom_auto, 'sxxvp', sxxvp, ldxios = lrxios )
-                  CALL iom_get( numrir, jpdom_auto, 'syyvp', syyvp, ldxios = lrxios )
-                  CALL iom_get( numrir, jpdom_auto, 'sxyvp', sxyvp, ldxios = lrxios )
+                  CALL iom_get( numrir, jpdom_auto, 'sxvp' , sxvp , psgn = -1._wp )
+                  CALL iom_get( numrir, jpdom_auto, 'syvp' , syvp , psgn = -1._wp )
+                  CALL iom_get( numrir, jpdom_auto, 'sxxvp', sxxvp )
+                  CALL iom_get( numrir, jpdom_auto, 'syyvp', syyvp )
+                  CALL iom_get( numrir, jpdom_auto, 'sxyvp', sxyvp )
                ELSE
                   sxap = 0._wp ;   syap = 0._wp    ;   sxxap = 0._wp    ;   syyap = 0._wp    ;   sxyap = 0._wp   ! melt pond fraction
@@ -1036,9 +1035,9 @@
                IF ( ln_pnd_lids ) THEN                               ! melt pond lid volume
                   IF( iom_varid( numrir, 'sxvl', ldstop = .FALSE. ) > 0 ) THEN
-                     CALL iom_get( numrir, jpdom_auto, 'sxvl' , sxvl , psgn = -1._wp, ldxios = lrxios )
-                     CALL iom_get( numrir, jpdom_auto, 'syvl' , syvl , psgn = -1._wp, ldxios = lrxios )
-                     CALL iom_get( numrir, jpdom_auto, 'sxxvl', sxxvl, ldxios = lrxios )
-                     CALL iom_get( numrir, jpdom_auto, 'syyvl', syyvl, ldxios = lrxios )
-                     CALL iom_get( numrir, jpdom_auto, 'sxyvl', sxyvl, ldxios = lrxios )
+                     CALL iom_get( numrir, jpdom_auto, 'sxvl' , sxvl , psgn = -1._wp )
+                     CALL iom_get( numrir, jpdom_auto, 'syvl' , syvl , psgn = -1._wp )
+                     CALL iom_get( numrir, jpdom_auto, 'sxxvl', sxxvl )
+                     CALL iom_get( numrir, jpdom_auto, 'syyvl', syyvl )
+                     CALL iom_get( numrir, jpdom_auto, 'sxyvl', sxyvl )
                   ELSE
                      sxvl = 0._wp; syvl = 0._wp    ;   sxxvl = 0._wp    ;   syyvl = 0._wp    ;   sxyvl = 0._wp   ! melt pond lid volume
@@ -1046,5 +1045,4 @@
                ENDIF
             ENDIF
-            IF(lrxios) CALL iom_swap(cxios_context)
             !
          ELSE                                   !**  start rheology from rest  **!
@@ -1079,47 +1077,46 @@
          !
          !                                                           ! ice thickness
-         IF( lwxios ) CALL iom_swap(      cw_icerst_cxt         )
-         CALL iom_rstput( iter, nitrst, numriw, 'sxice' , sxice,  ldxios = lwxios)
-         CALL iom_rstput( iter, nitrst, numriw, 'syice' , syice,  ldxios = lwxios)
-         CALL iom_rstput( iter, nitrst, numriw, 'sxxice', sxxice, ldxios = lwxios)
-         CALL iom_rstput( iter, nitrst, numriw, 'syyice', syyice, ldxios = lwxios)
-         CALL iom_rstput( iter, nitrst, numriw, 'sxyice', sxyice, ldxios = lwxios)
+         CALL iom_rstput( iter, nitrst, numriw, 'sxice' , sxice)
+         CALL iom_rstput( iter, nitrst, numriw, 'syice' , syice)
+         CALL iom_rstput( iter, nitrst, numriw, 'sxxice', sxxice)
+         CALL iom_rstput( iter, nitrst, numriw, 'syyice', syyice)
+         CALL iom_rstput( iter, nitrst, numriw, 'sxyice', sxyice)
          !                                                           ! snow thickness
-         CALL iom_rstput( iter, nitrst, numriw, 'sxsn'  , sxsn,  ldxios = lwxios )
-         CALL iom_rstput( iter, nitrst, numriw, 'sysn'  , sysn,  ldxios = lwxios )
-         CALL iom_rstput( iter, nitrst, numriw, 'sxxsn' , sxxsn, ldxios = lwxios )
-         CALL iom_rstput( iter, nitrst, numriw, 'syysn' , syysn, ldxios = lwxios )
-         CALL iom_rstput( iter, nitrst, numriw, 'sxysn' , sxysn, ldxios = lwxios )
+         CALL iom_rstput( iter, nitrst, numriw, 'sxsn'  , sxsn )
+         CALL iom_rstput( iter, nitrst, numriw, 'sysn'  , sysn )
+         CALL iom_rstput( iter, nitrst, numriw, 'sxxsn' , sxxsn )
+         CALL iom_rstput( iter, nitrst, numriw, 'syysn' , syysn )
+         CALL iom_rstput( iter, nitrst, numriw, 'sxysn' , sxysn )
          !                                                           ! ice concentration
-         CALL iom_rstput( iter, nitrst, numriw, 'sxa'   , sxa,  ldxios = lwxios  )
-         CALL iom_rstput( iter, nitrst, numriw, 'sya'   , sya,  ldxios = lwxios  )
-         CALL iom_rstput( iter, nitrst, numriw, 'sxxa'  , sxxa, ldxios = lwxios  )
-         CALL iom_rstput( iter, nitrst, numriw, 'syya'  , syya, ldxios = lwxios  )
-         CALL iom_rstput( iter, nitrst, numriw, 'sxya'  , sxya, ldxios = lwxios  )
+         CALL iom_rstput( iter, nitrst, numriw, 'sxa'   , sxa  )
+         CALL iom_rstput( iter, nitrst, numriw, 'sya'   , sya  )
+         CALL iom_rstput( iter, nitrst, numriw, 'sxxa'  , sxxa  )
+         CALL iom_rstput( iter, nitrst, numriw, 'syya'  , syya  )
+         CALL iom_rstput( iter, nitrst, numriw, 'sxya'  , sxya  )
          !                                                           ! ice salinity
-         CALL iom_rstput( iter, nitrst, numriw, 'sxsal' , sxsal,  ldxios = lwxios)
-         CALL iom_rstput( iter, nitrst, numriw, 'sysal' , sysal,  ldxios = lwxios)
-         CALL iom_rstput( iter, nitrst, numriw, 'sxxsal', sxxsal, ldxios = lwxios)
-         CALL iom_rstput( iter, nitrst, numriw, 'syysal', syysal, ldxios = lwxios)
-         CALL iom_rstput( iter, nitrst, numriw, 'sxysal', sxysal, ldxios = lwxios)
+         CALL iom_rstput( iter, nitrst, numriw, 'sxsal' , sxsal)
+         CALL iom_rstput( iter, nitrst, numriw, 'sysal' , sysal)
+         CALL iom_rstput( iter, nitrst, numriw, 'sxxsal', sxxsal)
+         CALL iom_rstput( iter, nitrst, numriw, 'syysal', syysal)
+         CALL iom_rstput( iter, nitrst, numriw, 'sxysal', sxysal)
          !                                                           ! ice age
-         CALL iom_rstput( iter, nitrst, numriw, 'sxage' , sxage,  ldxios = lwxios)
-         CALL iom_rstput( iter, nitrst, numriw, 'syage' , syage,  ldxios = lwxios)
-         CALL iom_rstput( iter, nitrst, numriw, 'sxxage', sxxage, ldxios = lwxios)
-         CALL iom_rstput( iter, nitrst, numriw, 'syyage', syyage, ldxios = lwxios)
-         CALL iom_rstput( iter, nitrst, numriw, 'sxyage', sxyage, ldxios = lwxios)
+         CALL iom_rstput( iter, nitrst, numriw, 'sxage' , sxage)
+         CALL iom_rstput( iter, nitrst, numriw, 'syage' , syage)
+         CALL iom_rstput( iter, nitrst, numriw, 'sxxage', sxxage)
+         CALL iom_rstput( iter, nitrst, numriw, 'syyage', syyage)
+         CALL iom_rstput( iter, nitrst, numriw, 'sxyage', sxyage)
          !                                                           ! snow layers heat content
          DO jk = 1, nlay_s
             WRITE(zchar1,'(I2.2)') jk
             znam = 'sxc0'//'_l'//zchar1  ;   z3d(:,:,:) = sxc0 (:,:,jk,:)
-            CALL iom_rstput( iter, nitrst, numriw, znam , z3d, ldxios = lwxios)
+            CALL iom_rstput( iter, nitrst, numriw, znam , z3d)
             znam = 'syc0'//'_l'//zchar1  ;   z3d(:,:,:) = syc0 (:,:,jk,:)
-            CALL iom_rstput( iter, nitrst, numriw, znam , z3d, ldxios = lwxios)
+            CALL iom_rstput( iter, nitrst, numriw, znam , z3d)
             znam = 'sxxc0'//'_l'//zchar1 ;   z3d(:,:,:) = sxxc0(:,:,jk,:)
-            CALL iom_rstput( iter, nitrst, numriw, znam , z3d, ldxios = lwxios)
+            CALL iom_rstput( iter, nitrst, numriw, znam , z3d)
             znam = 'syyc0'//'_l'//zchar1 ;   z3d(:,:,:) = syyc0(:,:,jk,:)
-            CALL iom_rstput( iter, nitrst, numriw, znam , z3d, ldxios = lwxios)
+            CALL iom_rstput( iter, nitrst, numriw, znam , z3d)
             znam = 'sxyc0'//'_l'//zchar1 ;   z3d(:,:,:) = sxyc0(:,:,jk,:)
-            CALL iom_rstput( iter, nitrst, numriw, znam , z3d, ldxios = lwxios)
+            CALL iom_rstput( iter, nitrst, numriw, znam , z3d)
          END DO
          !                                                           ! ice layers heat content
@@ -1127,37 +1124,36 @@
             WRITE(zchar1,'(I2.2)') jk
             znam = 'sxe'//'_l'//zchar1   ;   z3d(:,:,:) = sxe (:,:,jk,:)
-            CALL iom_rstput( iter, nitrst, numriw, znam , z3d, ldxios = lwxios)
+            CALL iom_rstput( iter, nitrst, numriw, znam , z3d)
             znam = 'sye'//'_l'//zchar1   ;   z3d(:,:,:) = sye (:,:,jk,:)
-            CALL iom_rstput( iter, nitrst, numriw, znam , z3d, ldxios = lwxios)
+            CALL iom_rstput( iter, nitrst, numriw, znam , z3d)
             znam = 'sxxe'//'_l'//zchar1  ;   z3d(:,:,:) = sxxe(:,:,jk,:)
-            CALL iom_rstput( iter, nitrst, numriw, znam , z3d, ldxios = lwxios)
+            CALL iom_rstput( iter, nitrst, numriw, znam , z3d)
             znam = 'syye'//'_l'//zchar1  ;   z3d(:,:,:) = syye(:,:,jk,:)
-            CALL iom_rstput( iter, nitrst, numriw, znam , z3d, ldxios = lwxios)
+            CALL iom_rstput( iter, nitrst, numriw, znam , z3d)
             znam = 'sxye'//'_l'//zchar1  ;   z3d(:,:,:) = sxye(:,:,jk,:)
-            CALL iom_rstput( iter, nitrst, numriw, znam , z3d, ldxios = lwxios)
+            CALL iom_rstput( iter, nitrst, numriw, znam , z3d)
          END DO
          !
          IF( ln_pnd_LEV ) THEN                                       ! melt pond fraction
-            CALL iom_rstput( iter, nitrst, numriw, 'sxap' , sxap , ldxios = lwxios )
-            CALL iom_rstput( iter, nitrst, numriw, 'syap' , syap , ldxios = lwxios )
-            CALL iom_rstput( iter, nitrst, numriw, 'sxxap', sxxap, ldxios = lwxios )
-            CALL iom_rstput( iter, nitrst, numriw, 'syyap', syyap, ldxios = lwxios )
-            CALL iom_rstput( iter, nitrst, numriw, 'sxyap', sxyap, ldxios = lwxios )
+            CALL iom_rstput( iter, nitrst, numriw, 'sxap' , sxap  )
+            CALL iom_rstput( iter, nitrst, numriw, 'syap' , syap  )
+            CALL iom_rstput( iter, nitrst, numriw, 'sxxap', sxxap )
+            CALL iom_rstput( iter, nitrst, numriw, 'syyap', syyap )
+            CALL iom_rstput( iter, nitrst, numriw, 'sxyap', sxyap )
             !                                                        ! melt pond volume
-            CALL iom_rstput( iter, nitrst, numriw, 'sxvp' , sxvp , ldxios = lwxios )
-            CALL iom_rstput( iter, nitrst, numriw, 'syvp' , syvp , ldxios = lwxios )
-            CALL iom_rstput( iter, nitrst, numriw, 'sxxvp', sxxvp, ldxios = lwxios )
-            CALL iom_rstput( iter, nitrst, numriw, 'syyvp', syyvp, ldxios = lwxios )
-            CALL iom_rstput( iter, nitrst, numriw, 'sxyvp', sxyvp, ldxios = lwxios )
+            CALL iom_rstput( iter, nitrst, numriw, 'sxvp' , sxvp  )
+            CALL iom_rstput( iter, nitrst, numriw, 'syvp' , syvp  )
+            CALL iom_rstput( iter, nitrst, numriw, 'sxxvp', sxxvp )
+            CALL iom_rstput( iter, nitrst, numriw, 'syyvp', syyvp )
+            CALL iom_rstput( iter, nitrst, numriw, 'sxyvp', sxyvp )
             !
             IF ( ln_pnd_lids ) THEN                                  ! melt pond lid volume
-               CALL iom_rstput( iter, nitrst, numriw, 'sxvl' , sxvl , ldxios = lwxios )
-               CALL iom_rstput( iter, nitrst, numriw, 'syvl' , syvl , ldxios = lwxios )
-               CALL iom_rstput( iter, nitrst, numriw, 'sxxvl', sxxvl, ldxios = lwxios )
-               CALL iom_rstput( iter, nitrst, numriw, 'syyvl', syyvl, ldxios = lwxios )
-               CALL iom_rstput( iter, nitrst, numriw, 'sxyvl', sxyvl, ldxios = lwxios )
+               CALL iom_rstput( iter, nitrst, numriw, 'sxvl' , sxvl  )
+               CALL iom_rstput( iter, nitrst, numriw, 'syvl' , syvl  )
+               CALL iom_rstput( iter, nitrst, numriw, 'sxxvl', sxxvl )
+               CALL iom_rstput( iter, nitrst, numriw, 'syyvl', syyvl )
+               CALL iom_rstput( iter, nitrst, numriw, 'sxyvl', sxyvl )
             ENDIF
          ENDIF
-         IF( lwxios ) CALL iom_swap(      cxios_context         )
          !
       ENDIF
Index: NEMO/branches/2020/dev_12905_xios_restart/src/ICE/icedyn_rhg_evp.F90
===================================================================
--- NEMO/branches/2020/dev_12905_xios_restart/src/ICE/icedyn_rhg_evp.F90	(revision 13931)
+++ NEMO/branches/2020/dev_12905_xios_restart/src/ICE/icedyn_rhg_evp.F90	(revision 13932)
@@ -1005,5 +1005,4 @@
          IF( ln_rstart ) THEN                   !* Read the restart file
             !
-            IF(lrxios) CALL iom_swap(cr_icerst_cxt)
             id1 = iom_varid( numrir, 'stress1_i' , ldstop = .FALSE. )
             id2 = iom_varid( numrir, 'stress2_i' , ldstop = .FALSE. )
@@ -1011,7 +1010,7 @@
             !
             IF( MIN( id1, id2, id3 ) > 0 ) THEN      ! fields exist
-               CALL iom_get( numrir, jpdom_auto, 'stress1_i' , stress1_i , cd_type = 'T', ldxios = lrxios )
-               CALL iom_get( numrir, jpdom_auto, 'stress2_i' , stress2_i , cd_type = 'T', ldxios = lrxios )
-               CALL iom_get( numrir, jpdom_auto, 'stress12_i', stress12_i, cd_type = 'F', ldxios = lrxios )
+               CALL iom_get( numrir, jpdom_auto, 'stress1_i' , stress1_i , cd_type = 'T' )
+               CALL iom_get( numrir, jpdom_auto, 'stress2_i' , stress2_i , cd_type = 'T' )
+               CALL iom_get( numrir, jpdom_auto, 'stress12_i', stress12_i, cd_type = 'F' )
             ELSE                                     ! start rheology from rest
                IF(lwp) WRITE(numout,*)
@@ -1021,5 +1020,4 @@
                stress12_i(:,:) = 0._wp
             ENDIF
-            IF(lrxios) CALL iom_swap(cxios_context)
          ELSE                                   !* Start from rest
             IF(lwp) WRITE(numout,*)
@@ -1035,9 +1033,7 @@
          iter = kt + nn_fsbc - 1             ! ice restarts are written at kt == nitrst - nn_fsbc + 1
          !
-         IF( lwxios ) CALL iom_swap(      cw_icerst_cxt         )
-         CALL iom_rstput( iter, nitrst, numriw, 'stress1_i' , stress1_i,  ldxios = lwxios )
-         CALL iom_rstput( iter, nitrst, numriw, 'stress2_i' , stress2_i,  ldxios = lwxios )
-         CALL iom_rstput( iter, nitrst, numriw, 'stress12_i', stress12_i, ldxios = lwxios )
-         IF( lwxios ) CALL iom_swap(      cxios_context         )
+         CALL iom_rstput( iter, nitrst, numriw, 'stress1_i' , stress1_i )
+         CALL iom_rstput( iter, nitrst, numriw, 'stress2_i' , stress2_i )
+         CALL iom_rstput( iter, nitrst, numriw, 'stress12_i', stress12_i )
          !
       ENDIF
Index: NEMO/branches/2020/dev_12905_xios_restart/src/ICE/icerst.F90
===================================================================
--- NEMO/branches/2020/dev_12905_xios_restart/src/ICE/icerst.F90	(revision 13931)
+++ NEMO/branches/2020/dev_12905_xios_restart/src/ICE/icerst.F90	(revision 13932)
@@ -95,6 +95,7 @@
                   clpname = TRIM(Agrif_CFixed())//"_"//clname
                ENDIF
-               CALL iom_init( cw_icerst_cxt, fname = TRIM(clpath)//TRIM(clpname), ld_closedef = .FALSE. )
-               CALL iom_swap(      cxios_context          )
+               numriw = iom_xios_setid(TRIM(clpath)//TRIM(clpname))
+               CALL iom_init( cw_icerst_cxt, kdid = numriw, ld_closedef = .FALSE. )
+               CALL iom_swap( cxios_context )
 #else
                clinfo = 'Can not use XIOS in rst_opn'
@@ -134,25 +135,25 @@
          IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~~'         
       ENDIF
-
+      
       ! Write in numriw (if iter == nitrst)
       ! ------------------ 
       !                                                                        ! calendar control
-      IF( lwxios ) CALL iom_swap(      cw_icerst_cxt         )
-      CALL iom_rstput( iter, nitrst, numriw, 'nn_fsbc', REAL( nn_fsbc, wp ), ldxios = lwxios )      ! time-step 
-      CALL iom_rstput( iter, nitrst, numriw, 'kt_ice' , REAL( iter   , wp ), ldxios = lwxios )      ! date
-      CALL iom_delay_rst( 'WRITE', 'ICE', numriw )   ! save only ice delayed global communication variables
+      CALL iom_rstput( iter, nitrst, numriw, 'nn_fsbc', REAL( nn_fsbc, wp ) )      ! time-step 
+      CALL iom_rstput( iter, nitrst, numriw, 'kt_ice' , REAL( iter   , wp ) )      ! date
+      
+      IF(.NOT.lwxios) CALL iom_delay_rst( 'WRITE', 'ICE', numriw )   ! save only ice delayed global communication variables
 
       ! Prognostic variables
-      CALL iom_rstput( iter, nitrst, numriw, 'v_i'  , v_i  , ldxios = lwxios )
-      CALL iom_rstput( iter, nitrst, numriw, 'v_s'  , v_s  , ldxios = lwxios )
-      CALL iom_rstput( iter, nitrst, numriw, 'sv_i' , sv_i , ldxios = lwxios )
-      CALL iom_rstput( iter, nitrst, numriw, 'a_i'  , a_i  , ldxios = lwxios )
-      CALL iom_rstput( iter, nitrst, numriw, 't_su' , t_su , ldxios = lwxios )
-      CALL iom_rstput( iter, nitrst, numriw, 'u_ice', u_ice, ldxios = lwxios )
-      CALL iom_rstput( iter, nitrst, numriw, 'v_ice', v_ice, ldxios = lwxios )
-      CALL iom_rstput( iter, nitrst, numriw, 'oa_i' , oa_i , ldxios = lwxios )
-      CALL iom_rstput( iter, nitrst, numriw, 'a_ip' , a_ip , ldxios = lwxios )
-      CALL iom_rstput( iter, nitrst, numriw, 'v_ip' , v_ip , ldxios = lwxios )
-      CALL iom_rstput( iter, nitrst, numriw, 'v_il' , v_il , ldxios = lwxios )
+      CALL iom_rstput( iter, nitrst, numriw, 'v_i'  , v_i   )
+      CALL iom_rstput( iter, nitrst, numriw, 'v_s'  , v_s   )
+      CALL iom_rstput( iter, nitrst, numriw, 'sv_i' , sv_i  )
+      CALL iom_rstput( iter, nitrst, numriw, 'a_i'  , a_i   )
+      CALL iom_rstput( iter, nitrst, numriw, 't_su' , t_su  )
+      CALL iom_rstput( iter, nitrst, numriw, 'u_ice', u_ice )
+      CALL iom_rstput( iter, nitrst, numriw, 'v_ice', v_ice )
+      CALL iom_rstput( iter, nitrst, numriw, 'oa_i' , oa_i  )
+      CALL iom_rstput( iter, nitrst, numriw, 'a_ip' , a_ip  )
+      CALL iom_rstput( iter, nitrst, numriw, 'v_ip' , v_ip  )
+      CALL iom_rstput( iter, nitrst, numriw, 'v_il' , v_il  )
       ! Snow enthalpy
       DO jk = 1, nlay_s 
@@ -160,5 +161,5 @@
          znam = 'e_s'//'_l'//zchar1
          z3d(:,:,:) = e_s(:,:,jk,:)
-         CALL iom_rstput( iter, nitrst, numriw, znam , z3d, ldxios = lwxios )
+         CALL iom_rstput( iter, nitrst, numriw, znam , z3d )
       END DO
       ! Ice enthalpy
@@ -167,12 +168,11 @@
          znam = 'e_i'//'_l'//zchar1
          z3d(:,:,:) = e_i(:,:,jk,:)
-         CALL iom_rstput( iter, nitrst, numriw, znam , z3d, ldxios = lwxios )
+         CALL iom_rstput( iter, nitrst, numriw, znam , z3d )
       END DO
       ! fields needed for Met Office (Jules) coupling
       IF( ln_cpl ) THEN
-         CALL iom_rstput( iter, nitrst, numriw, 'cnd_ice', cnd_ice, ldxios = lwxios )
-         CALL iom_rstput( iter, nitrst, numriw, 't1_ice' , t1_ice,  ldxios = lwxios )
-      ENDIF
-      IF( lwxios ) CALL iom_swap(      cxios_context         )
+         CALL iom_rstput( iter, nitrst, numriw, 'cnd_ice', cnd_ice )
+         CALL iom_rstput( iter, nitrst, numriw, 't1_ice' , t1_ice )
+      ENDIF
       !
 
@@ -184,4 +184,6 @@
          ELSE
             CALL iom_context_finalize(      cw_icerst_cxt          )
+            iom_file(numriw)%nfid       = 0
+            numriw = 0
          ENDIF
          lrst_ice = .FALSE.
@@ -220,11 +222,10 @@
           cr_icerst_cxt = 'si3_rst'
           IF(lwp) WRITE(numout,*) 'Enable restart reading by XIOS for SI3'
-          IF( TRIM(Agrif_CFixed()) == '0' ) THEN
-             clpname = cn_icerst_in
-          ELSE
-             clpname = TRIM(Agrif_CFixed())//"_"//cn_icerst_in   
-          ENDIF
-          CALL iom_init( cr_icerst_cxt, fname = TRIM(cn_icerst_indir)//'/'//TRIM(clpname), &
-                                          idfp = iom_file(numrir)%nfid, ld_closedef = .TRUE. )
+!         IF( TRIM(Agrif_CFixed()) == '0' ) THEN
+!            clpname = cn_icerst_in
+!         ELSE
+!            clpname = TRIM(Agrif_CFixed())//"_"//cn_icerst_in   
+!         ENDIF
+          CALL iom_init( cr_icerst_cxt, kdid = numrir, ld_closedef = .TRUE. )
       ENDIF
 
@@ -235,8 +236,7 @@
       IF( id0 > 0 ) THEN   ! == case of a normal restart == !
          !                 ! ------------------------------ !
-         IF(lrxios) CALL iom_swap(cr_icerst_cxt) 
          ! Time info
-         CALL iom_get( numrir, 'nn_fsbc', zfice, ldxios = lrxios )
-         CALL iom_get( numrir, 'kt_ice' , ziter, ldxios = lrxios )    
+         CALL iom_get( numrir, 'nn_fsbc', zfice )
+         CALL iom_get( numrir, 'kt_ice' , ziter )    
          IF(lwp) WRITE(numout,*) '   read ice restart file at time step    : ', ziter
          IF(lwp) WRITE(numout,*) '   in any case we force it to nit000 - 1 : ', nit000 - 1
@@ -253,16 +253,16 @@
 
          ! --- mandatory fields --- ! 
-         CALL iom_get( numrir, jpdom_auto, 'v_i'  , v_i  , ldxios = lrxios )
-         CALL iom_get( numrir, jpdom_auto, 'v_s'  , v_s  , ldxios = lrxios )
-         CALL iom_get( numrir, jpdom_auto, 'sv_i' , sv_i , ldxios = lrxios )
-         CALL iom_get( numrir, jpdom_auto, 'a_i'  , a_i  , ldxios = lrxios )
-         CALL iom_get( numrir, jpdom_auto, 't_su' , t_su , ldxios = lrxios )
-         CALL iom_get( numrir, jpdom_auto, 'u_ice', u_ice, cd_type = 'U', psgn = -1._wp, ldxios = lrxios )
-         CALL iom_get( numrir, jpdom_auto, 'v_ice', v_ice, cd_type = 'V', psgn = -1._wp, ldxios = lrxios )
+         CALL iom_get( numrir, jpdom_auto, 'v_i'  , v_i   )
+         CALL iom_get( numrir, jpdom_auto, 'v_s'  , v_s   )
+         CALL iom_get( numrir, jpdom_auto, 'sv_i' , sv_i  )
+         CALL iom_get( numrir, jpdom_auto, 'a_i'  , a_i   )
+         CALL iom_get( numrir, jpdom_auto, 't_su' , t_su  )
+         CALL iom_get( numrir, jpdom_auto, 'u_ice', u_ice, cd_type = 'U', psgn = -1._wp )
+         CALL iom_get( numrir, jpdom_auto, 'v_ice', v_ice, cd_type = 'V', psgn = -1._wp )
          ! Snow enthalpy
          DO jk = 1, nlay_s
             WRITE(zchar1,'(I2.2)') jk
             znam = 'e_s'//'_l'//zchar1
-            CALL iom_get( numrir, jpdom_auto, znam , z3d, ldxios = lrxios )
+            CALL iom_get( numrir, jpdom_auto, znam , z3d )
             e_s(:,:,jk,:) = z3d(:,:,:)
          END DO
@@ -271,5 +271,5 @@
             WRITE(zchar1,'(I2.2)') jk
             znam = 'e_i'//'_l'//zchar1
-            CALL iom_get( numrir, jpdom_auto, znam , z3d, ldxios = lrxios )
+            CALL iom_get( numrir, jpdom_auto, znam , z3d )
             e_i(:,:,jk,:) = z3d(:,:,:)
          END DO
@@ -278,5 +278,5 @@
          id1 = iom_varid( numrir, 'oa_i' , ldstop = .FALSE. )
          IF( id1 > 0 ) THEN                       ! fields exist
-            CALL iom_get( numrir, jpdom_auto, 'oa_i', oa_i, ldxios = lrxios )
+            CALL iom_get( numrir, jpdom_auto, 'oa_i', oa_i )
          ELSE                                     ! start from rest
             IF(lwp) WRITE(numout,*) '   ==>>   previous run without ice age output then set it to zero'
@@ -286,6 +286,6 @@
          id2 = iom_varid( numrir, 'a_ip' , ldstop = .FALSE. )
          IF( id2 > 0 ) THEN                       ! fields exist
-            CALL iom_get( numrir, jpdom_auto, 'a_ip' , a_ip, ldxios = lrxios )
-            CALL iom_get( numrir, jpdom_auto, 'v_ip' , v_ip, ldxios = lrxios )
+            CALL iom_get( numrir, jpdom_auto, 'a_ip' , a_ip )
+            CALL iom_get( numrir, jpdom_auto, 'v_ip' , v_ip )
          ELSE                                     ! start from rest
             IF(lwp) WRITE(numout,*) '   ==>>   previous run without melt ponds output then set it to zero'
@@ -296,5 +296,5 @@
          id3 = iom_varid( numrir, 'v_il' , ldstop = .FALSE. )
          IF( id3 > 0 ) THEN
-            CALL iom_get( numrir, jpdom_auto, 'v_il', v_il, ldxios = lrxios)
+            CALL iom_get( numrir, jpdom_auto, 'v_il', v_il)
          ELSE
             IF(lwp) WRITE(numout,*) '   ==>>   previous run without melt ponds lids output then set it to zero'
@@ -306,6 +306,6 @@
             id5 = iom_varid( numrir, 't1_ice'  , ldstop = .FALSE. )
             IF( id4 > 0 .AND. id5 > 0 ) THEN         ! fields exist
-               CALL iom_get( numrir, jpdom_auto, 'cnd_ice', cnd_ice, ldxios = lrxios )
-               CALL iom_get( numrir, jpdom_auto, 't1_ice' , t1_ice , ldxios = lrxios )
+               CALL iom_get( numrir, jpdom_auto, 'cnd_ice', cnd_ice )
+               CALL iom_get( numrir, jpdom_auto, 't1_ice' , t1_ice  )
             ELSE                                     ! start from rest
                IF(lwp) WRITE(numout,*) '   ==>>   previous run without conductivity output then set it to zero'
@@ -315,6 +315,5 @@
          ENDIF
 
-         CALL iom_delay_rst( 'READ', 'ICE', numrir )   ! read only ice delayed global communication variables
-         IF(lrxios) CALL iom_swap(cxios_context)
+         IF(.NOT.lrxios) CALL iom_delay_rst( 'READ', 'ICE', numrir )   ! read only ice delayed global communication variables
          !                 ! ---------------------------------- !
       ELSE                 ! == case of a simplified restart == !
Index: NEMO/branches/2020/dev_12905_xios_restart/src/ICE/icestp.F90
===================================================================
--- NEMO/branches/2020/dev_12905_xios_restart/src/ICE/icestp.F90	(revision 13931)
+++ NEMO/branches/2020/dev_12905_xios_restart/src/ICE/icestp.F90	(revision 13932)
@@ -292,6 +292,6 @@
       !
       IF( ln_rstart )  THEN
-          CALL iom_close( numrir )  ! close input ice restart file
-          IF(lrxios) CALL iom_context_finalize(      cr_icerst_cxt         )
+         CALL iom_close( numrir )  ! close input ice restart file
+         IF(lrxios) CALL iom_context_finalize(      cr_icerst_cxt         )
       ENDIF
       !
Index: NEMO/branches/2020/dev_12905_xios_restart/src/ICE/iceupdate.F90
===================================================================
--- NEMO/branches/2020/dev_12905_xios_restart/src/ICE/iceupdate.F90	(revision 13931)
+++ NEMO/branches/2020/dev_12905_xios_restart/src/ICE/iceupdate.F90	(revision 13932)
@@ -427,8 +427,6 @@
             !
             IF( id1 > 0 ) THEN                       ! fields exist
-               IF(lrxios) CALL iom_swap(cr_icerst_cxt)
-               CALL iom_get( numrir, jpdom_auto, 'snwice_mass'  , snwice_mass  , ldxios = lrxios )
-               CALL iom_get( numrir, jpdom_auto, 'snwice_mass_b', snwice_mass_b, ldxios = lrxios )
-               IF(lrxios) CALL iom_swap(cxios_context)
+               CALL iom_get( numrir, jpdom_auto, 'snwice_mass'  , snwice_mass   )
+               CALL iom_get( numrir, jpdom_auto, 'snwice_mass_b', snwice_mass_b )
             ELSE                                     ! start from rest
                IF(lwp) WRITE(numout,*) '   ==>>   previous run without snow-ice mass output then set it'
@@ -447,8 +445,6 @@
          iter = kt + nn_fsbc - 1             ! ice restarts are written at kt == nitrst - nn_fsbc + 1
          !
-         IF( lwxios ) CALL iom_swap(      cw_icerst_cxt         )
-         CALL iom_rstput( iter, nitrst, numriw, 'snwice_mass'  , snwice_mass,   ldxios = lwxios )
-         CALL iom_rstput( iter, nitrst, numriw, 'snwice_mass_b', snwice_mass_b, ldxios = lwxios )
-         IF( lwxios ) CALL iom_swap(      cxios_context         )
+         CALL iom_rstput( iter, nitrst, numriw, 'snwice_mass'  , snwice_mass   )
+         CALL iom_rstput( iter, nitrst, numriw, 'snwice_mass_b', snwice_mass_b )
          !
       ENDIF
Index: NEMO/branches/2020/dev_12905_xios_restart/src/OCE/DIA/diahsb.F90
===================================================================
--- NEMO/branches/2020/dev_12905_xios_restart/src/OCE/DIA/diahsb.F90	(revision 13931)
+++ NEMO/branches/2020/dev_12905_xios_restart/src/OCE/DIA/diahsb.F90	(revision 13932)
@@ -267,23 +267,21 @@
             IF(lwp) WRITE(numout,*) '   dia_hsb_rst : read hsb restart at it= ', kt,' date= ', ndastp
             IF(lwp) WRITE(numout,*)
-            IF( lrxios ) CALL iom_swap( TRIM(cr_ocerst_cxt) )
-            CALL iom_get( numror, 'frc_v', frc_v, ldxios = lrxios )
-            CALL iom_get( numror, 'frc_t', frc_t, ldxios = lrxios )
-            CALL iom_get( numror, 'frc_s', frc_s, ldxios = lrxios )
+            CALL iom_get( numror, 'frc_v', frc_v )
+            CALL iom_get( numror, 'frc_t', frc_t )
+            CALL iom_get( numror, 'frc_s', frc_s )
             IF( ln_linssh ) THEN
-               CALL iom_get( numror, 'frc_wn_t', frc_wn_t, ldxios = lrxios )
-               CALL iom_get( numror, 'frc_wn_s', frc_wn_s, ldxios = lrxios )
+               CALL iom_get( numror, 'frc_wn_t', frc_wn_t )
+               CALL iom_get( numror, 'frc_wn_s', frc_wn_s )
             ENDIF
-            CALL iom_get( numror, jpdom_auto, 'surf_ini'  , surf_ini  , ldxios = lrxios ) ! ice sheet coupling
-            CALL iom_get( numror, jpdom_auto, 'ssh_ini'   , ssh_ini   , ldxios = lrxios )
-            CALL iom_get( numror, jpdom_auto, 'e3t_ini'   , e3t_ini   , ldxios = lrxios )
-            CALL iom_get( numror, jpdom_auto, 'tmask_ini' , tmask_ini , ldxios = lrxios )
-            CALL iom_get( numror, jpdom_auto, 'hc_loc_ini', hc_loc_ini, ldxios = lrxios )
-            CALL iom_get( numror, jpdom_auto, 'sc_loc_ini', sc_loc_ini, ldxios = lrxios )
+            CALL iom_get( numror, jpdom_auto, 'surf_ini'  , surf_ini   ) ! ice sheet coupling
+            CALL iom_get( numror, jpdom_auto, 'ssh_ini'   , ssh_ini    )
+            CALL iom_get( numror, jpdom_auto, 'e3t_ini'   , e3t_ini    )
+            CALL iom_get( numror, jpdom_auto, 'tmask_ini' , tmask_ini  )
+            CALL iom_get( numror, jpdom_auto, 'hc_loc_ini', hc_loc_ini )
+            CALL iom_get( numror, jpdom_auto, 'sc_loc_ini', sc_loc_ini )
             IF( ln_linssh ) THEN
-               CALL iom_get( numror, jpdom_auto, 'ssh_hc_loc_ini', ssh_hc_loc_ini, ldxios = lrxios )
-               CALL iom_get( numror, jpdom_auto, 'ssh_sc_loc_ini', ssh_sc_loc_ini, ldxios = lrxios )
+               CALL iom_get( numror, jpdom_auto, 'ssh_hc_loc_ini', ssh_hc_loc_ini )
+               CALL iom_get( numror, jpdom_auto, 'ssh_sc_loc_ini', ssh_sc_loc_ini )
             ENDIF
-            IF( lrxios ) CALL iom_swap( TRIM(cxios_context) )
          ELSE
             IF(lwp) WRITE(numout,*)
@@ -325,23 +323,21 @@
          IF(lwp) WRITE(numout,*)
          !
-         IF( lwxios ) CALL iom_swap(      cw_ocerst_cxt          )
-         CALL iom_rstput( kt, nitrst, numrow, 'frc_v', frc_v, ldxios = lwxios )
-         CALL iom_rstput( kt, nitrst, numrow, 'frc_t', frc_t, ldxios = lwxios )
-         CALL iom_rstput( kt, nitrst, numrow, 'frc_s', frc_s, ldxios = lwxios )
+         CALL iom_rstput( kt, nitrst, numrow, 'frc_v', frc_v )
+         CALL iom_rstput( kt, nitrst, numrow, 'frc_t', frc_t )
+         CALL iom_rstput( kt, nitrst, numrow, 'frc_s', frc_s )
          IF( ln_linssh ) THEN
-            CALL iom_rstput( kt, nitrst, numrow, 'frc_wn_t', frc_wn_t, ldxios = lwxios )
-            CALL iom_rstput( kt, nitrst, numrow, 'frc_wn_s', frc_wn_s, ldxios = lwxios )
+            CALL iom_rstput( kt, nitrst, numrow, 'frc_wn_t', frc_wn_t )
+            CALL iom_rstput( kt, nitrst, numrow, 'frc_wn_s', frc_wn_s )
          ENDIF
-         CALL iom_rstput( kt, nitrst, numrow, 'surf_ini'  , surf_ini  , ldxios = lwxios )      ! ice sheet coupling
-         CALL iom_rstput( kt, nitrst, numrow, 'ssh_ini'   , ssh_ini   , ldxios = lwxios )
-         CALL iom_rstput( kt, nitrst, numrow, 'e3t_ini'   , e3t_ini   , ldxios = lwxios )
-         CALL iom_rstput( kt, nitrst, numrow, 'tmask_ini' , tmask_ini , ldxios = lwxios )
-         CALL iom_rstput( kt, nitrst, numrow, 'hc_loc_ini', hc_loc_ini, ldxios = lwxios )
-         CALL iom_rstput( kt, nitrst, numrow, 'sc_loc_ini', sc_loc_ini, ldxios = lwxios )
+         CALL iom_rstput( kt, nitrst, numrow, 'surf_ini'  , surf_ini   )      ! ice sheet coupling
+         CALL iom_rstput( kt, nitrst, numrow, 'ssh_ini'   , ssh_ini    )
+         CALL iom_rstput( kt, nitrst, numrow, 'e3t_ini'   , e3t_ini    )
+         CALL iom_rstput( kt, nitrst, numrow, 'tmask_ini' , tmask_ini  )
+         CALL iom_rstput( kt, nitrst, numrow, 'hc_loc_ini', hc_loc_ini )
+         CALL iom_rstput( kt, nitrst, numrow, 'sc_loc_ini', sc_loc_ini )
          IF( ln_linssh ) THEN
-            CALL iom_rstput( kt, nitrst, numrow, 'ssh_hc_loc_ini', ssh_hc_loc_ini, ldxios = lwxios )
-            CALL iom_rstput( kt, nitrst, numrow, 'ssh_sc_loc_ini', ssh_sc_loc_ini, ldxios = lwxios )
+            CALL iom_rstput( kt, nitrst, numrow, 'ssh_hc_loc_ini', ssh_hc_loc_ini )
+            CALL iom_rstput( kt, nitrst, numrow, 'ssh_sc_loc_ini', ssh_sc_loc_ini )
          ENDIF
-         IF( lwxios ) CALL iom_swap(      cxios_context          )
          !
       ENDIF
Index: NEMO/branches/2020/dev_12905_xios_restart/src/OCE/DOM/daymod.F90
===================================================================
--- NEMO/branches/2020/dev_12905_xios_restart/src/OCE/DOM/daymod.F90	(revision 13931)
+++ NEMO/branches/2020/dev_12905_xios_restart/src/OCE/DOM/daymod.F90	(revision 13932)
@@ -316,8 +316,7 @@
 
       IF( TRIM(cdrw) == 'READ' ) THEN
-         IF( lrxios ) CALL iom_swap( TRIM(cr_ocerst_cxt) )
          IF( iom_varid( numror, 'kt', ldstop = .FALSE. ) > 0 ) THEN
             ! Get Calendar informations
-            CALL iom_get( numror, 'kt', zkt, ldxios = lrxios )   ! last time-step of previous run
+            CALL iom_get( numror, 'kt', zkt )   ! last time-step of previous run
             IF(lwp) THEN
                WRITE(numout,*) ' *** Info read in restart : '
@@ -338,8 +337,8 @@
             IF ( nrstdt == 2 ) THEN
                ! read the parameters corresponding to nit000 - 1 (last time step of previous run)
-               CALL iom_get( numror, 'ndastp', zndastp, ldxios = lrxios )
+               CALL iom_get( numror, 'ndastp', zndastp )
                ndastp = NINT( zndastp )
-               CALL iom_get( numror, 'adatrj', adatrj , ldxios = lrxios )
-	       CALL iom_get( numror, 'ntime' , ktime  , ldxios = lrxios )
+               CALL iom_get( numror, 'adatrj', adatrj  )
+	       CALL iom_get( numror, 'ntime' , ktime   )
                nn_time0 = NINT(ktime)
                ! calculate start time in hours and minutes
@@ -384,5 +383,4 @@
             adatrj = ( REAL( nit000-1, wp ) * rn_Dt ) / rday
          ENDIF
-         IF( lrxios ) CALL iom_swap( TRIM(cxios_context) )
          IF( ABS(adatrj  - REAL(NINT(adatrj),wp)) < 0.1 / rday )   adatrj = REAL(NINT(adatrj),wp)   ! avoid truncation error
          !
@@ -403,11 +401,9 @@
          ENDIF
          ! calendar control
-         IF( lwxios ) CALL iom_swap(      cw_ocerst_cxt          )
-         CALL iom_rstput( kt, nitrst, numrow, 'kt'     , REAL( kt    , wp)  , ldxios = lwxios )   ! time-step
-         CALL iom_rstput( kt, nitrst, numrow, 'ndastp' , REAL( ndastp, wp)  , ldxios = lwxios )   ! date
-         CALL iom_rstput( kt, nitrst, numrow, 'adatrj' , adatrj             , ldxios = lwxios            )   ! number of elapsed days since
+         CALL iom_rstput( kt, nitrst, numrow, 'kt'     , REAL( kt    , wp)   )   ! time-step
+         CALL iom_rstput( kt, nitrst, numrow, 'ndastp' , REAL( ndastp, wp)   )   ! date
+         CALL iom_rstput( kt, nitrst, numrow, 'adatrj' , adatrj              )   ! number of elapsed days since
          !                                                                                                   ! the begining of the run [s]
-         CALL iom_rstput( kt, nitrst, numrow, 'ntime'  , REAL( nn_time0, wp), ldxios = lwxios ) ! time
-         IF( lwxios ) CALL iom_swap(      cxios_context          )
+         CALL iom_rstput( kt, nitrst, numrow, 'ntime'  , REAL( nn_time0, wp) ) ! time
       ENDIF
       !
Index: NEMO/branches/2020/dev_12905_xios_restart/src/OCE/DOM/domqco.F90
===================================================================
--- NEMO/branches/2020/dev_12905_xios_restart/src/OCE/DOM/domqco.F90	(revision 13931)
+++ NEMO/branches/2020/dev_12905_xios_restart/src/OCE/DOM/domqco.F90	(revision 13932)
@@ -212,6 +212,6 @@
             !
             IF( MIN( id1, id2 ) > 0 ) THEN       ! all required arrays exist
-               CALL iom_get( numror, jpdom_auto, 'sshb'   , ssh(:,:,Kbb), ldxios = lrxios    )
-               CALL iom_get( numror, jpdom_auto, 'sshn'   , ssh(:,:,Kmm), ldxios = lrxios    )
+               CALL iom_get( numror, jpdom_auto, 'sshb'   , ssh(:,:,Kbb)    )
+               CALL iom_get( numror, jpdom_auto, 'sshn'   , ssh(:,:,Kmm)    )
                ! needed to restart if land processor not computed
                IF(lwp) write(numout,*) 'qe_rst_read : ssh(:,:,Kbb) and ssh(:,:,Kmm) found in restart files'
@@ -227,5 +227,5 @@
                IF(lwp) write(numout,*) 'sshn set equal to sshb.'
                IF(lwp) write(numout,*) 'neuler is forced to 0'
-               CALL iom_get( numror, jpdom_auto, 'sshb', ssh(:,:,Kbb), ldxios = lrxios )
+               CALL iom_get( numror, jpdom_auto, 'sshb', ssh(:,:,Kbb) )
                ssh(:,:,Kmm) = ssh(:,:,Kbb)
                l_1st_euler = .TRUE.
@@ -234,5 +234,5 @@
                IF(lwp) write(numout,*) 'sshb set equal to sshn.'
                IF(lwp) write(numout,*) 'neuler is forced to 0'
-               CALL iom_get( numror, jpdom_auto, 'sshn', ssh(:,:,Kmm), ldxios = lrxios )
+               CALL iom_get( numror, jpdom_auto, 'sshn', ssh(:,:,Kmm) )
                ssh(:,:,Kbb) = ssh(:,:,Kmm)
                l_1st_euler = .TRUE.
Index: NEMO/branches/2020/dev_12905_xios_restart/src/OCE/DOM/domvvl.F90
===================================================================
--- NEMO/branches/2020/dev_12905_xios_restart/src/OCE/DOM/domvvl.F90	(revision 13931)
+++ NEMO/branches/2020/dev_12905_xios_restart/src/OCE/DOM/domvvl.F90	(revision 13932)
@@ -785,6 +785,5 @@
          IF( ln_rstart ) THEN                   !* Read the restart file
             CALL rst_read_open                  !  open the restart file if necessary
-            IF( lrxios ) CALL iom_swap( TRIM(cr_ocerst_cxt) )
-            CALL iom_get( numror, jpdom_auto, 'sshn'   , ssh(:,:,Kmm), ldxios = lrxios    )
+            CALL iom_get( numror, jpdom_auto, 'sshn'   , ssh(:,:,Kmm)    )
             !
             id1 = iom_varid( numror, 'e3t_b', ldstop = .FALSE. )
@@ -799,6 +798,6 @@
             !
             IF( MIN( id1, id2 ) > 0 ) THEN       ! all required arrays exist
-               CALL iom_get( numror, jpdom_auto, 'e3t_b', e3t(:,:,:,Kbb), ldxios = lrxios )
-               CALL iom_get( numror, jpdom_auto, 'e3t_n', e3t(:,:,:,Kmm), ldxios = lrxios )
+               CALL iom_get( numror, jpdom_auto, 'e3t_b', e3t(:,:,:,Kbb) )
+               CALL iom_get( numror, jpdom_auto, 'e3t_n', e3t(:,:,:,Kmm) )
                ! needed to restart if land processor not computed 
                IF(lwp) write(numout,*) 'dom_vvl_rst : e3t(:,:,:,Kbb) and e3t(:,:,:,Kmm) found in restart files'
@@ -814,5 +813,5 @@
                IF(lwp) write(numout,*) 'e3t_n set equal to e3t_b.'
                IF(lwp) write(numout,*) 'l_1st_euler is forced to true'
-               CALL iom_get( numror, jpdom_auto, 'e3t_b', e3t(:,:,:,Kbb), ldxios = lrxios )
+               CALL iom_get( numror, jpdom_auto, 'e3t_b', e3t(:,:,:,Kbb) )
                e3t(:,:,:,Kmm) = e3t(:,:,:,Kbb)
                l_1st_euler = .true.
@@ -821,5 +820,5 @@
                IF(lwp) write(numout,*) 'e3t_b set equal to e3t_n.'
                IF(lwp) write(numout,*) 'l_1st_euler is forced to true'
-               CALL iom_get( numror, jpdom_auto, 'e3t_n', e3t(:,:,:,Kmm), ldxios = lrxios )
+               CALL iom_get( numror, jpdom_auto, 'e3t_n', e3t(:,:,:,Kmm) )
                e3t(:,:,:,Kbb) = e3t(:,:,:,Kmm)
                l_1st_euler = .true.
@@ -846,6 +845,6 @@
                !                          ! ----------------------- !
                IF( MIN( id3, id4 ) > 0 ) THEN  ! all required arrays exist
-                  CALL iom_get( numror, jpdom_auto, 'tilde_e3t_b', tilde_e3t_b(:,:,:), ldxios = lrxios )
-                  CALL iom_get( numror, jpdom_auto, 'tilde_e3t_n', tilde_e3t_n(:,:,:), ldxios = lrxios )
+                  CALL iom_get( numror, jpdom_auto, 'tilde_e3t_b', tilde_e3t_b(:,:,:) )
+                  CALL iom_get( numror, jpdom_auto, 'tilde_e3t_n', tilde_e3t_n(:,:,:) )
                ELSE                            ! one at least array is missing
                   tilde_e3t_b(:,:,:) = 0.0_wp
@@ -856,5 +855,5 @@
                   !                       ! ------------ !
                   IF( id5 > 0 ) THEN  ! required array exists
-                     CALL iom_get( numror, jpdom_auto, 'hdiv_lf', hdiv_lf(:,:,:), ldxios = lrxios )
+                     CALL iom_get( numror, jpdom_auto, 'hdiv_lf', hdiv_lf(:,:,:) )
                   ELSE                ! array is missing
                      hdiv_lf(:,:,:) = 0.0_wp
@@ -862,5 +861,4 @@
                ENDIF
             ENDIF
-            IF( lrxios ) CALL iom_swap( TRIM(cxios_context) )
             !
          ELSE                                   !* Initialize at "rest"
@@ -930,23 +928,21 @@
          !                                   ! ===================
          IF(lwp) WRITE(numout,*) '---- dom_vvl_rst ----'
-         IF( lwxios ) CALL iom_swap(      cw_ocerst_cxt          )
          !                                           ! --------- !
          !                                           ! all cases !
          !                                           ! --------- !
-         CALL iom_rstput( kt, nitrst, numrow, 'e3t_b', e3t(:,:,:,Kbb), ldxios = lwxios )
-         CALL iom_rstput( kt, nitrst, numrow, 'e3t_n', e3t(:,:,:,Kmm), ldxios = lwxios )
+         CALL iom_rstput( kt, nitrst, numrow, 'e3t_b', e3t(:,:,:,Kbb) )
+         CALL iom_rstput( kt, nitrst, numrow, 'e3t_n', e3t(:,:,:,Kmm) )
          !                                           ! ----------------------- !
          IF( ln_vvl_ztilde .OR. ln_vvl_layer ) THEN  ! z_tilde and layer cases !
             !                                        ! ----------------------- !
-            CALL iom_rstput( kt, nitrst, numrow, 'tilde_e3t_b', tilde_e3t_b(:,:,:), ldxios = lwxios)
-            CALL iom_rstput( kt, nitrst, numrow, 'tilde_e3t_n', tilde_e3t_n(:,:,:), ldxios = lwxios)
+            CALL iom_rstput( kt, nitrst, numrow, 'tilde_e3t_b', tilde_e3t_b(:,:,:))
+            CALL iom_rstput( kt, nitrst, numrow, 'tilde_e3t_n', tilde_e3t_n(:,:,:))
          END IF
          !                                           ! -------------!    
          IF( ln_vvl_ztilde ) THEN                    ! z_tilde case !
             !                                        ! ------------ !
-            CALL iom_rstput( kt, nitrst, numrow, 'hdiv_lf', hdiv_lf(:,:,:), ldxios = lwxios)
+            CALL iom_rstput( kt, nitrst, numrow, 'hdiv_lf', hdiv_lf(:,:,:))
          ENDIF
          !
-         IF( lwxios ) CALL iom_swap(      cxios_context          )
       ENDIF
       !
Index: NEMO/branches/2020/dev_12905_xios_restart/src/OCE/DYN/dynspg_ts.F90
===================================================================
--- NEMO/branches/2020/dev_12905_xios_restart/src/OCE/DYN/dynspg_ts.F90	(revision 13931)
+++ NEMO/branches/2020/dev_12905_xios_restart/src/OCE/DYN/dynspg_ts.F90	(revision 13932)
@@ -899,23 +899,22 @@
       IF( TRIM(cdrw) == 'READ' ) THEN        ! Read/initialise 
          !                                   ! ---------------
-         IF( lrxios ) CALL iom_swap( TRIM(cr_ocerst_cxt) )
          IF( ln_rstart .AND. ln_bt_fw .AND. (.NOT.l_1st_euler) ) THEN    !* Read the restart file
-            CALL iom_get( numror, jpdom_auto, 'ub2_b'  , ub2_b  (:,:), cd_type = 'U', psgn = -1._wp, ldxios = lrxios )   
-            CALL iom_get( numror, jpdom_auto, 'vb2_b'  , vb2_b  (:,:), cd_type = 'V', psgn = -1._wp, ldxios = lrxios ) 
-            CALL iom_get( numror, jpdom_auto, 'un_bf'  , un_bf  (:,:), cd_type = 'U', psgn = -1._wp, ldxios = lrxios )   
-            CALL iom_get( numror, jpdom_auto, 'vn_bf'  , vn_bf  (:,:), cd_type = 'V', psgn = -1._wp, ldxios = lrxios ) 
+            CALL iom_get( numror, jpdom_auto, 'ub2_b'  , ub2_b  (:,:), cd_type = 'U', psgn = -1._wp )   
+            CALL iom_get( numror, jpdom_auto, 'vb2_b'  , vb2_b  (:,:), cd_type = 'V', psgn = -1._wp ) 
+            CALL iom_get( numror, jpdom_auto, 'un_bf'  , un_bf  (:,:), cd_type = 'U', psgn = -1._wp )   
+            CALL iom_get( numror, jpdom_auto, 'vn_bf'  , vn_bf  (:,:), cd_type = 'V', psgn = -1._wp ) 
             IF( .NOT.ln_bt_av ) THEN
-               CALL iom_get( numror, jpdom_auto, 'sshbb_e'  , sshbb_e(:,:), cd_type = 'T', psgn =  1._wp, ldxios = lrxios )   
-               CALL iom_get( numror, jpdom_auto, 'ubb_e'    ,   ubb_e(:,:), cd_type = 'U', psgn = -1._wp, ldxios = lrxios )   
-               CALL iom_get( numror, jpdom_auto, 'vbb_e'    ,   vbb_e(:,:), cd_type = 'V', psgn = -1._wp, ldxios = lrxios )
-               CALL iom_get( numror, jpdom_auto, 'sshb_e'   ,  sshb_e(:,:), cd_type = 'T', psgn =  1._wp, ldxios = lrxios ) 
-               CALL iom_get( numror, jpdom_auto, 'ub_e'     ,    ub_e(:,:), cd_type = 'U', psgn = -1._wp, ldxios = lrxios )   
-               CALL iom_get( numror, jpdom_auto, 'vb_e'     ,    vb_e(:,:), cd_type = 'V', psgn = -1._wp, ldxios = lrxios )
+               CALL iom_get( numror, jpdom_auto, 'sshbb_e'  , sshbb_e(:,:), cd_type = 'T', psgn =  1._wp )   
+               CALL iom_get( numror, jpdom_auto, 'ubb_e'    ,   ubb_e(:,:), cd_type = 'U', psgn = -1._wp )   
+               CALL iom_get( numror, jpdom_auto, 'vbb_e'    ,   vbb_e(:,:), cd_type = 'V', psgn = -1._wp )
+               CALL iom_get( numror, jpdom_auto, 'sshb_e'   ,  sshb_e(:,:), cd_type = 'T', psgn =  1._wp ) 
+               CALL iom_get( numror, jpdom_auto, 'ub_e'     ,    ub_e(:,:), cd_type = 'U', psgn = -1._wp )   
+               CALL iom_get( numror, jpdom_auto, 'vb_e'     ,    vb_e(:,:), cd_type = 'V', psgn = -1._wp )
             ENDIF
 #if defined key_agrif
             ! Read time integrated fluxes
             IF ( .NOT.Agrif_Root() ) THEN
-               CALL iom_get( numror, jpdom_auto, 'ub2_i_b'  , ub2_i_b(:,:), cd_type = 'U', psgn = -1._wp, ldxios = lrxios )   
-               CALL iom_get( numror, jpdom_auto, 'vb2_i_b'  , vb2_i_b(:,:), cd_type = 'V', psgn = -1._wp, ldxios = lrxios )
+               CALL iom_get( numror, jpdom_auto, 'ub2_i_b'  , ub2_i_b(:,:), cd_type = 'U', psgn = -1._wp )   
+               CALL iom_get( numror, jpdom_auto, 'vb2_i_b'  , vb2_i_b(:,:), cd_type = 'V', psgn = -1._wp )
             ELSE
                ub2_i_b(:,:) = 0._wp   ;   vb2_i_b(:,:) = 0._wp   ! used in the 1st update of agrif
@@ -932,31 +931,28 @@
 #endif
          ENDIF
-         IF( lrxios ) CALL iom_swap( TRIM(cxios_context) )
          !
       ELSEIF( TRIM(cdrw) == 'WRITE' ) THEN   ! Create restart file
          !                                   ! -------------------
          IF(lwp) WRITE(numout,*) '---- ts_rst ----'
-         IF( lwxios ) CALL iom_swap(      cw_ocerst_cxt          )
-         CALL iom_rstput( kt, nitrst, numrow, 'ub2_b'   , ub2_b  (:,:), ldxios = lwxios )
-         CALL iom_rstput( kt, nitrst, numrow, 'vb2_b'   , vb2_b  (:,:), ldxios = lwxios )
-         CALL iom_rstput( kt, nitrst, numrow, 'un_bf'   , un_bf  (:,:), ldxios = lwxios )
-         CALL iom_rstput( kt, nitrst, numrow, 'vn_bf'   , vn_bf  (:,:), ldxios = lwxios )
+         CALL iom_rstput( kt, nitrst, numrow, 'ub2_b'   , ub2_b  (:,:) )
+         CALL iom_rstput( kt, nitrst, numrow, 'vb2_b'   , vb2_b  (:,:) )
+         CALL iom_rstput( kt, nitrst, numrow, 'un_bf'   , un_bf  (:,:) )
+         CALL iom_rstput( kt, nitrst, numrow, 'vn_bf'   , vn_bf  (:,:) )
          !
          IF (.NOT.ln_bt_av) THEN
-            CALL iom_rstput( kt, nitrst, numrow, 'sshbb_e'  , sshbb_e(:,:), ldxios = lwxios ) 
-            CALL iom_rstput( kt, nitrst, numrow, 'ubb_e'    ,   ubb_e(:,:), ldxios = lwxios )
-            CALL iom_rstput( kt, nitrst, numrow, 'vbb_e'    ,   vbb_e(:,:), ldxios = lwxios )
-            CALL iom_rstput( kt, nitrst, numrow, 'sshb_e'   ,  sshb_e(:,:), ldxios = lwxios )
-            CALL iom_rstput( kt, nitrst, numrow, 'ub_e'     ,    ub_e(:,:), ldxios = lwxios )
-            CALL iom_rstput( kt, nitrst, numrow, 'vb_e'     ,    vb_e(:,:), ldxios = lwxios )
+            CALL iom_rstput( kt, nitrst, numrow, 'sshbb_e'  , sshbb_e(:,:) ) 
+            CALL iom_rstput( kt, nitrst, numrow, 'ubb_e'    ,   ubb_e(:,:) )
+            CALL iom_rstput( kt, nitrst, numrow, 'vbb_e'    ,   vbb_e(:,:) )
+            CALL iom_rstput( kt, nitrst, numrow, 'sshb_e'   ,  sshb_e(:,:) )
+            CALL iom_rstput( kt, nitrst, numrow, 'ub_e'     ,    ub_e(:,:) )
+            CALL iom_rstput( kt, nitrst, numrow, 'vb_e'     ,    vb_e(:,:) )
          ENDIF
 #if defined key_agrif
          ! Save time integrated fluxes
          IF ( .NOT.Agrif_Root() ) THEN
-            CALL iom_rstput( kt, nitrst, numrow, 'ub2_i_b'  , ub2_i_b(:,:), ldxios = lwxios )
-            CALL iom_rstput( kt, nitrst, numrow, 'vb2_i_b'  , vb2_i_b(:,:), ldxios = lwxios )
+            CALL iom_rstput( kt, nitrst, numrow, 'ub2_i_b'  , ub2_i_b(:,:) )
+            CALL iom_rstput( kt, nitrst, numrow, 'vb2_i_b'  , vb2_i_b(:,:) )
          ENDIF
 #endif
-         IF( lwxios ) CALL iom_swap(      cxios_context          )
       ENDIF
       !
Index: NEMO/branches/2020/dev_12905_xios_restart/src/OCE/IOM/in_out_manager.F90
===================================================================
--- NEMO/branches/2020/dev_12905_xios_restart/src/OCE/IOM/in_out_manager.F90	(revision 13931)
+++ NEMO/branches/2020/dev_12905_xios_restart/src/OCE/IOM/in_out_manager.F90	(revision 13932)
@@ -89,9 +89,14 @@
    LOGICAL ::   lrst_abl              !: logical to control the abl restart write 
    INTEGER ::   numror = 0            !: logical unit for ocean restart (read). Init to 0 is needed for SAS (in daymod.F90)
-   INTEGER ::   numrir                !: logical unit for ice   restart (read)
-   INTEGER ::   numrar                !: logical unit for abl   restart (read)
-   INTEGER ::   numrow                !: logical unit for ocean restart (write)
-   INTEGER ::   numriw                !: logical unit for ice   restart (write)
-   INTEGER ::   numraw                !: logical unit for abl   restart (write)
+   INTEGER ::   numrir = 0            !: logical unit for ice   restart (read)
+   INTEGER ::   numrar = 0            !: logical unit for abl   restart (read)
+   INTEGER ::   numrow = 0            !: logical unit for ocean restart (write)
+   INTEGER ::   numriw = 0            !: logical unit for ice   restart (write)
+   INTEGER ::   numraw = 0            !: logical unit for abl   restart (write)
+   INTEGER ::   numrtr = 0            !: trc restart (read )
+   INTEGER ::   numrtw = 0            !: trc restart (write )
+   INTEGER ::   numrsr = 0            !: logical unit for sed restart (read)
+   INTEGER ::   numrsw = 0            !: logical unit for sed restart (write)
+
    INTEGER ::   nrst_lst              !: number of restart to output next
 
@@ -165,13 +170,13 @@
    LOGICAL       ::   lwp      = .FALSE.    !: boolean : true on the 1st processor only .OR. sn_cfctl%l_oceout=T
    LOGICAL       ::   lsp_area = .TRUE.     !: to make a control print over a specific area
-   CHARACTER(LEN=lc) ::   cxios_context         !: context name used in xios
-   CHARACTER(LEN=lc) ::   cr_ocerst_cxt        !: context name used in xios to read OCE restart
-   CHARACTER(LEN=lc) ::   cw_ocerst_cxt        !: context name used in xios to write OCE restart file
-   CHARACTER(LEN=lc) ::   cr_icerst_cxt       !: context name used in xios to read SI3 restart
-   CHARACTER(LEN=lc) ::   cw_icerst_cxt       !: context name used in xios to write SI3 restart file
-   CHARACTER(LEN=lc) ::   cr_toprst_cxt       !: context name used in xios to read TOP restart
-   CHARACTER(LEN=lc) ::   cw_toprst_cxt       !: context name used in xios to write TOP restart file
-   CHARACTER(LEN=lc) ::   cr_sedrst_cxt       !: context name used in xios to read SEDIMENT restart
-   CHARACTER(LEN=lc) ::   cw_sedrst_cxt       !: context name used in xios to write SEDIMENT restart file
+   CHARACTER(LEN=lc) ::   cxios_context     !: context name used in xios
+   CHARACTER(LEN=lc) ::   cr_ocerst_cxt     !: context name used in xios to read OCE restart
+   CHARACTER(LEN=lc) ::   cw_ocerst_cxt     !: context name used in xios to write OCE restart file
+   CHARACTER(LEN=lc) ::   cr_icerst_cxt     !: context name used in xios to read SI3 restart
+   CHARACTER(LEN=lc) ::   cw_icerst_cxt     !: context name used in xios to write SI3 restart file
+   CHARACTER(LEN=lc) ::   cr_toprst_cxt     !: context name used in xios to read TOP restart
+   CHARACTER(LEN=lc) ::   cw_toprst_cxt     !: context name used in xios to write TOP restart file
+   CHARACTER(LEN=lc) ::   cr_sedrst_cxt     !: context name used in xios to read SEDIMENT restart
+   CHARACTER(LEN=lc) ::   cw_sedrst_cxt     !: context name used in xios to write SEDIMENT restart file
 
 
Index: NEMO/branches/2020/dev_12905_xios_restart/src/OCE/IOM/iom.F90
===================================================================
--- NEMO/branches/2020/dev_12905_xios_restart/src/OCE/IOM/iom.F90	(revision 13931)
+++ NEMO/branches/2020/dev_12905_xios_restart/src/OCE/IOM/iom.F90	(revision 13932)
@@ -60,4 +60,5 @@
    PUBLIC iom_chkatt, iom_getatt, iom_putatt, iom_getszuld, iom_rstput, iom_delay_rst, iom_put
    PUBLIC iom_use, iom_context_finalize, iom_update_file_name, iom_miss_val
+   PUBLIC iom_xios_setid
 
    PRIVATE iom_rp0d_sp, iom_rp1d_sp, iom_rp2d_sp, iom_rp3d_sp
@@ -73,4 +74,5 @@
    PRIVATE iom_set_rst_context, iom_set_vars_active
 # endif
+   PRIVATE set_xios_context
    PRIVATE iom_set_rstw_active
 
@@ -103,5 +105,5 @@
 CONTAINS
 
-   SUBROUTINE iom_init( cdname, fname, idfp, ld_closedef ) 
+   SUBROUTINE iom_init( cdname, kdid, ld_closedef ) 
       !!----------------------------------------------------------------------
       !!                     ***  ROUTINE   ***
@@ -111,6 +113,5 @@
       !!----------------------------------------------------------------------
       CHARACTER(len=*),           INTENT(in)  :: cdname
-      CHARACTER(len=*), OPTIONAL, INTENT(in)  :: fname
-      INTEGER         , OPTIONAL, INTENT(in)  :: idfp         ! pointer to netcdf file for restart reading with XIOS
+      INTEGER         , OPTIONAL, INTENT(in)  :: kdid          
       LOGICAL         , OPTIONAL, INTENT(in)  :: ld_closedef
 #if defined key_iomput
@@ -267,13 +268,13 @@
       ! automatic definitions of some of the xml attributs
       IF(llrstr) THEN
-         IF(PRESENT(idfp)) THEN
+         IF(PRESENT(kdid)) THEN
             CALL iom_set_rst_context(.TRUE.)
 !set which fields will be read from restart file
-            CALL iom_set_vars_active(fname, idfp)
+            CALL iom_set_vars_active(kdid)
          ELSE
             CALL ctl_stop( 'iom_init:', 'restart read with XIOS: missing pointer to NETCDF file' )
          ENDIF
       ELSE IF(llrstw) THEN
-         CALL iom_set_rstw_file(fname)
+         CALL iom_set_rstw_file(iom_file(kdid)%name)
       ELSE
          CALL set_xmlatt
@@ -327,5 +328,5 @@
    END SUBROUTINE iom_init_closedef
 
-   SUBROUTINE iom_set_vars_active(cdfname, idnum)
+   SUBROUTINE iom_set_vars_active(idnum)
       !!---------------------------------------------------------------------
       !!                   ***  SUBROUTINE  iom_set_vars_active  ***
@@ -335,6 +336,6 @@
       !!               id of the file is assumed to be rrestart.
       !!---------------------------------------------------------------------
-      CHARACTER(len=*), INTENT(IN) :: cdfname
-      INTEGER         , INTENT(IN) :: idnum 
+      INTEGER, INTENT(IN) :: idnum 
+      
 #if defined key_iomput
       INTEGER                                    :: ndims, nvars, natts, unlimitedDimId, dimlen, xtype,mdims
@@ -347,8 +348,10 @@
       CHARACTER(LEN=nf90_max_name), ALLOCATABLE  :: indimnames(:)
       CHARACTER(LEN=nf90_max_name)               :: dimname, varname
+      INTEGER                                    :: iln
+      CHARACTER(LEN=lc)                          :: fname
       LOGICAL                                    :: lmeta
 !metadata in restart file for restart read with XIOS
-      INTEGER, PARAMETER :: NMETA = 10
-      CHARACTER(LEN=lc)  :: meta(NMETA)
+      INTEGER, PARAMETER                         :: NMETA = 10
+      CHARACTER(LEN=lc)                          :: meta(NMETA)
 
 
@@ -364,19 +367,27 @@
       meta(10) = "numcat"
 
-      clinfo = '          iom_set_vars_active, file: '//TRIM(cdfname)
+      clinfo = '          iom_set_vars_active, file: '//TRIM(iom_file(idnum)%name)
+
+      iln = INDEX( iom_file(idnum)%name, '.nc' )
+!XIOS doee not need .nc
+      IF(iln > 0) THEN
+        fname =  iom_file(idnum)%name(1:iln-1)
+      ELSE
+        fname =  iom_file(idnum)%name
+      ENDIF
 
 !set name of the restart file and enable available fields
       CALL xios_get_handle("file_definition", filegroup_hdl )
       CALL xios_add_child(filegroup_hdl, file_hdl, 'rrestart')
-      CALL xios_set_file_attr( "rrestart", name=trim(cdfname), type="one_file", &
-           par_access="collective", enabled=.TRUE., mode="read",                &
-                                                    output_freq=xios_timestep   )
-
-      CALL iom_nf90_check( nf90_inquire(idnum, ndims, nvars, natts ), clinfo )
+      CALL xios_set_file_attr( "rrestart", name=fname, type="one_file",      &
+           par_access="collective", enabled=.TRUE., mode="read",              &
+                                                    output_freq=xios_timestep )
+
+      CALL iom_nf90_check( nf90_inquire(iom_file(idnum)%nfid, ndims, nvars, natts ), clinfo )
       ALLOCATE(indimlens(ndims), indimnames(ndims))
-      CALL iom_nf90_check( nf90_inquire(idnum, unlimitedDimId = unlimitedDimId ), clinfo )
+      CALL iom_nf90_check( nf90_inquire(iom_file(idnum)%nfid, unlimitedDimId = unlimitedDimId ), clinfo )
 
       DO idim = 1, ndims
-         CALL iom_nf90_check( nf90_inquire_dimension(idnum, idim, dimname, dimlen ), clinfo )
+         CALL iom_nf90_check( nf90_inquire_dimension(iom_file(idnum)%nfid, idim, dimname, dimlen ), clinfo )
          indimlens(idim) = dimlen
          indimnames(idim) = dimname
@@ -385,5 +396,5 @@
       DO jv =1, nvars
          lmeta = .FALSE.
-         CALL iom_nf90_check( nf90_inquire_variable(idnum, jv, varname, xtype, ndims, dimids, natts ), clinfo )
+         CALL iom_nf90_check( nf90_inquire_variable(iom_file(idnum)%nfid, jv, varname, xtype, ndims, dimids, natts ), clinfo )
          DO i = 1, NMETA
            IF(varname == meta(i)) THEN
@@ -438,5 +449,5 @@
 
 !set name of the restart file and enable available fields
-      IF(lwp) WRITE(numout,*) 'Setting restart filename (for XIOS write) to: ',cdrst_file
+      IF(lwp) WRITE(numout,*) 'Setting restart filename (for XIOS write) to: ', TRIM(cdrst_file)
       CALL xios_get_handle("file_definition", filegroup_hdl )
       CALL xios_add_child(filegroup_hdl, file_hdl, 'wrestart')
@@ -519,5 +530,5 @@
 
    FUNCTION iom_axis(idlev) result(axis_ref)
-     !!---------------------------------------------------------------------
+      !!---------------------------------------------------------------------
       !!                   ***  FUNCTION  iom_axis  ***
       !!
@@ -542,6 +553,31 @@
    END FUNCTION iom_axis
 
+   FUNCTION iom_xios_setid(cdname) result(kid)
+     !!---------------------------------------------------------------------
+      !!                   ***  FUNCTION    ***
+      !!
+      !! ** Purpose : this function returns first available id to keep information about file 
+      !!              sets filename in iom_file structure and sets name
+      !!              of XIOS context depending on cdcomp
+      !!              corresponds to iom_nf90_open
+      !!---------------------------------------------------------------------
+      CHARACTER(len=*), INTENT(in   ) :: cdname      ! File name
+      INTEGER                         :: kid      ! identifier of the opened file
+      INTEGER                         :: jl
+
+      kid = 0
+      DO jl = jpmax_files, 1, -1
+         IF( iom_file(jl)%nfid == 0 )   kid = jl
+      ENDDO
+
+      iom_file(kid)%name   = TRIM(cdname)
+      iom_file(kid)%nfid   = 1
+      iom_file(kid)%nvars  = 0
+      iom_file(kid)%irec   = -1
+
+   END FUNCTION iom_xios_setid
+
    SUBROUTINE iom_set_rst_context(ld_rstr) 
-     !!---------------------------------------------------------------------
+      !!---------------------------------------------------------------------
       !!                   ***  SUBROUTINE  iom_set_rst_context  ***
       !!
@@ -578,4 +614,43 @@
 #endif
    END SUBROUTINE iom_set_rst_context
+
+
+   SUBROUTINE set_xios_context(kdid, cdcont) 
+      !!---------------------------------------------------------------------
+      !!                   ***  SUBROUTINE  iom_set_rst_context  ***
+      !!
+      !! ** Purpose : set correct XIOS context based on kdid
+      !!               
+      !!---------------------------------------------------------------------
+      INTEGER,           INTENT(IN)     :: kdid           ! Identifier of the file
+      CHARACTER(LEN=lc), INTENT(OUT)    :: cdcont         ! name of the context for XIOS read/write
+      
+      cdcont = "NONE"
+
+      IF(lrxios) THEN
+         IF(kdid == numror) THEN
+            cdcont = cr_ocerst_cxt
+         ELSEIF(kdid == numrir) THEN
+            cdcont = cr_icerst_cxt 
+         ELSEIF(kdid == numrtr) THEN
+            cdcont = cr_toprst_cxt
+         ELSEIF(kdid == numrsr) THEN
+            cdcont = cr_sedrst_cxt
+         ENDIF
+      ENDIF
+
+      IF(lwxios) THEN
+         IF(kdid == numrow) THEN
+            cdcont = cw_ocerst_cxt
+         ELSEIF(kdid == numriw) THEN
+            cdcont = cw_icerst_cxt
+         ELSEIF(kdid == numrtw) THEN
+            cdcont = cw_toprst_cxt
+         ELSEIF(kdid == numrsw) THEN
+            cdcont = cw_sedrst_cxt
+         ENDIF
+      ENDIF
+   END SUBROUTINE set_xios_context
+
 
    SUBROUTINE iom_swap( cdname )
@@ -837,5 +912,5 @@
    !!                   INTERFACE iom_get
    !!----------------------------------------------------------------------
-   SUBROUTINE iom_g0d_sp( kiomid, cdvar, pvar, ktime, ldxios )
+   SUBROUTINE iom_g0d_sp( kiomid, cdvar, pvar, ktime )
       INTEGER         , INTENT(in   )                 ::   kiomid    ! Identifier of the file
       CHARACTER(len=*), INTENT(in   )                 ::   cdvar     ! Name of the variable
@@ -843,5 +918,4 @@
       REAL(dp)                                        ::   ztmp_pvar ! tmp var to read field
       INTEGER         , INTENT(in   ),     OPTIONAL   ::   ktime     ! record number
-      LOGICAL         , INTENT(in   ),     OPTIONAL   ::   ldxios    ! use xios to read restart
       !
       INTEGER                                         ::   idvar     ! variable id
@@ -851,10 +925,9 @@
       CHARACTER(LEN=100)                              ::   clname    ! file name
       CHARACTER(LEN=1)                                ::   cldmspc   !
-      LOGICAL                                         ::   llxios
-      !
-      llxios = .FALSE.
-      IF( PRESENT(ldxios) ) llxios = ldxios
-
-      IF(.NOT.llxios) THEN  ! read data using default library
+      CHARACTER(LEN=lc)                               ::   context
+      !
+      CALL set_xios_context(kiomid, context)
+
+      IF(context == "NONE") THEN  ! read data using default library
          itime = 1
          IF( PRESENT(ktime) ) itime = ktime
@@ -879,5 +952,7 @@
 #if defined key_iomput
          IF(lwp) WRITE(numout,*) 'XIOS RST READ (0D): ', trim(cdvar)
+         CALL iom_swap(context)
          CALL xios_recv_field( trim(cdvar), pvar)
+         CALL iom_swap(cxios_context)
 #else
          WRITE(ctmp1,*) 'Can not use XIOS in iom_g0d, file: '//trim(clname)//', var:'//trim(cdvar)
@@ -887,10 +962,9 @@
    END SUBROUTINE iom_g0d_sp
 
-   SUBROUTINE iom_g0d_dp( kiomid, cdvar, pvar, ktime, ldxios )
+   SUBROUTINE iom_g0d_dp( kiomid, cdvar, pvar, ktime )
       INTEGER         , INTENT(in   )                 ::   kiomid    ! Identifier of the file
       CHARACTER(len=*), INTENT(in   )                 ::   cdvar     ! Name of the variable
       REAL(dp)        , INTENT(  out)                 ::   pvar      ! read field
       INTEGER         , INTENT(in   ),     OPTIONAL   ::   ktime     ! record number
-      LOGICAL         , INTENT(in   ),     OPTIONAL   ::   ldxios    ! use xios to read restart
       !
       INTEGER                                         ::   idvar     ! variable id
@@ -900,10 +974,9 @@
       CHARACTER(LEN=100)                              ::   clname    ! file name
       CHARACTER(LEN=1)                                ::   cldmspc   !
-      LOGICAL                                         ::   llxios
-      !
-      llxios = .FALSE.
-      IF( PRESENT(ldxios) ) llxios = ldxios
-
-      IF(.NOT.llxios) THEN  ! read data using default library
+      CHARACTER(LEN=lc)                               ::   context
+      !
+      CALL set_xios_context(kiomid, context)
+
+      IF(context == "NONE") THEN  ! read data using default library
          itime = 1
          IF( PRESENT(ktime) ) itime = ktime
@@ -927,5 +1000,7 @@
 #if defined key_iomput
          IF(lwp) WRITE(numout,*) 'XIOS RST READ (0D): ', trim(cdvar)
+         CALL iom_swap(context)
          CALL xios_recv_field( trim(cdvar), pvar)
+         CALL iom_swap(cxios_context)
 #else
          WRITE(ctmp1,*) 'Can not use XIOS in iom_g0d, file: '//trim(clname)//', var:'//trim(cdvar)
@@ -935,5 +1010,5 @@
    END SUBROUTINE iom_g0d_dp
 
-   SUBROUTINE iom_g1d_sp( kiomid, kdom, cdvar, pvar, ktime, kstart, kcount, ldxios )
+   SUBROUTINE iom_g1d_sp( kiomid, kdom, cdvar, pvar, ktime, kstart, kcount )
       INTEGER         , INTENT(in   )                         ::   kiomid    ! Identifier of the file
       INTEGER         , INTENT(in   )                         ::   kdom      ! Type of domain to be read
@@ -944,5 +1019,4 @@
       INTEGER         , INTENT(in   ), DIMENSION(1), OPTIONAL ::   kstart    ! start axis position of the reading 
       INTEGER         , INTENT(in   ), DIMENSION(1), OPTIONAL ::   kcount    ! number of points in each axis
-      LOGICAL         , INTENT(in   ),               OPTIONAL ::   ldxios    ! read data using XIOS
       !
       IF( kiomid > 0 ) THEN
@@ -950,6 +1024,5 @@
             ALLOCATE(ztmp_pvar(size(pvar,1)))
             CALL iom_get_123d( kiomid, kdom       , cdvar        , pv_r1d=ztmp_pvar,   &
-              &                                                     ktime=ktime, kstart=kstart, kcount=kcount, &
-              &                                                     ldxios=ldxios )
+              &                                                     ktime=ktime, kstart=kstart, kcount=kcount )
             pvar = ztmp_pvar
             DEALLOCATE(ztmp_pvar)
@@ -959,5 +1032,5 @@
 
 
-   SUBROUTINE iom_g1d_dp( kiomid, kdom, cdvar, pvar, ktime, kstart, kcount, ldxios )
+   SUBROUTINE iom_g1d_dp( kiomid, kdom, cdvar, pvar, ktime, kstart, kcount )
       INTEGER         , INTENT(in   )                         ::   kiomid    ! Identifier of the file
       INTEGER         , INTENT(in   )                         ::   kdom      ! Type of domain to be read
@@ -967,14 +1040,12 @@
       INTEGER         , INTENT(in   ), DIMENSION(1), OPTIONAL ::   kstart    ! start axis position of the reading 
       INTEGER         , INTENT(in   ), DIMENSION(1), OPTIONAL ::   kcount    ! number of points in each axis
-      LOGICAL         , INTENT(in   ),               OPTIONAL ::   ldxios    ! read data using XIOS
       !
       IF( kiomid > 0 ) THEN
          IF( iom_file(kiomid)%nfid > 0 ) CALL iom_get_123d( kiomid, kdom       , cdvar        , pv_r1d=pvar,   &
-              &                                                     ktime=ktime, kstart=kstart, kcount=kcount, &
-              &                                                     ldxios=ldxios )
+              &                                                     ktime=ktime, kstart=kstart, kcount=kcount)
       ENDIF
    END SUBROUTINE iom_g1d_dp
 
-   SUBROUTINE iom_g2d_sp( kiomid, kdom, cdvar, pvar, ktime, cd_type, psgn, kfill, kstart, kcount, ldxios)
+   SUBROUTINE iom_g2d_sp( kiomid, kdom, cdvar, pvar, ktime, cd_type, psgn, kfill, kstart, kcount)
       INTEGER         , INTENT(in   )                         ::   kiomid    ! Identifier of the file
       INTEGER         , INTENT(in   )                         ::   kdom      ! Type of domain to be read
@@ -988,5 +1059,4 @@
       INTEGER         , INTENT(in   ), DIMENSION(2), OPTIONAL ::   kstart    ! start axis position of the reading 
       INTEGER         , INTENT(in   ), DIMENSION(2), OPTIONAL ::   kcount    ! number of points in each axis
-      LOGICAL         , INTENT(in   ),               OPTIONAL ::   ldxios    ! read data using XIOS
       !
       IF( kiomid > 0 ) THEN
@@ -995,5 +1065,5 @@
             CALL iom_get_123d( kiomid, kdom, cdvar      , pv_r2d = ztmp_pvar  , ktime = ktime,   &
              &                                                      cd_type = cd_type, psgn   = psgn  , kfill = kfill,   &
-             &                                                      kstart  = kstart , kcount = kcount, ldxios=ldxios  )
+             &                                                      kstart  = kstart , kcount = kcount  )
             pvar = ztmp_pvar
             DEALLOCATE(ztmp_pvar)
@@ -1002,5 +1072,5 @@
    END SUBROUTINE iom_g2d_sp
 
-   SUBROUTINE iom_g2d_dp( kiomid, kdom, cdvar, pvar, ktime, cd_type, psgn, kfill, kstart, kcount, ldxios)
+   SUBROUTINE iom_g2d_dp( kiomid, kdom, cdvar, pvar, ktime, cd_type, psgn, kfill, kstart, kcount)
       INTEGER         , INTENT(in   )                         ::   kiomid    ! Identifier of the file
       INTEGER         , INTENT(in   )                         ::   kdom      ! Type of domain to be read
@@ -1013,14 +1083,13 @@
       INTEGER         , INTENT(in   ), DIMENSION(2), OPTIONAL ::   kstart    ! start axis position of the reading 
       INTEGER         , INTENT(in   ), DIMENSION(2), OPTIONAL ::   kcount    ! number of points in each axis
-      LOGICAL         , INTENT(in   ),               OPTIONAL ::   ldxios    ! read data using XIOS
       !
       IF( kiomid > 0 ) THEN
          IF( iom_file(kiomid)%nfid > 0 ) CALL iom_get_123d( kiomid, kdom, cdvar      , pv_r2d = pvar  , ktime = ktime,   &
             &                                                       cd_type = cd_type, psgn   = psgn  , kfill = kfill,   &
-            &                                                       kstart  = kstart , kcount = kcount, ldxios=ldxios  )
+            &                                                       kstart  = kstart , kcount = kcount                )
       ENDIF
    END SUBROUTINE iom_g2d_dp
 
-   SUBROUTINE iom_g3d_sp( kiomid, kdom, cdvar, pvar, ktime, cd_type, psgn, kfill, kstart, kcount, ldxios )
+   SUBROUTINE iom_g3d_sp( kiomid, kdom, cdvar, pvar, ktime, cd_type, psgn, kfill, kstart, kcount )
       INTEGER         , INTENT(in   )                         ::   kiomid    ! Identifier of the file
       INTEGER         , INTENT(in   )                         ::   kdom      ! Type of domain to be read
@@ -1034,5 +1103,4 @@
       INTEGER         , INTENT(in   ), DIMENSION(3), OPTIONAL ::   kstart    ! start axis position of the reading 
       INTEGER         , INTENT(in   ), DIMENSION(3), OPTIONAL ::   kcount    ! number of points in each axis
-      LOGICAL         , INTENT(in   ),               OPTIONAL ::   ldxios    ! read data using XIOS
       !
       IF( kiomid > 0 ) THEN
@@ -1041,5 +1109,5 @@
             CALL iom_get_123d( kiomid, kdom, cdvar      , pv_r3d = ztmp_pvar  , ktime = ktime,   &
             &                                                       cd_type = cd_type, psgn   = psgn  , kfill = kfill,   &
-            &                                                       kstart  = kstart , kcount = kcount, ldxios=ldxios  )
+            &                                                       kstart  = kstart , kcount = kcount                )
             pvar = ztmp_pvar
             DEALLOCATE(ztmp_pvar)
@@ -1048,5 +1116,5 @@
    END SUBROUTINE iom_g3d_sp
 
-   SUBROUTINE iom_g3d_dp( kiomid, kdom, cdvar, pvar, ktime, cd_type, psgn, kfill, kstart, kcount, ldxios )
+   SUBROUTINE iom_g3d_dp( kiomid, kdom, cdvar, pvar, ktime, cd_type, psgn, kfill, kstart, kcount )
       INTEGER         , INTENT(in   )                         ::   kiomid    ! Identifier of the file
       INTEGER         , INTENT(in   )                         ::   kdom      ! Type of domain to be read
@@ -1059,5 +1127,4 @@
       INTEGER         , INTENT(in   ), DIMENSION(3), OPTIONAL ::   kstart    ! start axis position of the reading 
       INTEGER         , INTENT(in   ), DIMENSION(3), OPTIONAL ::   kcount    ! number of points in each axis
-      LOGICAL         , INTENT(in   ),               OPTIONAL ::   ldxios    ! read data using XIOS
       !
       IF( kiomid > 0 ) THEN
@@ -1065,5 +1132,5 @@
             CALL iom_get_123d( kiomid, kdom, cdvar      , pv_r3d = pvar  , ktime = ktime,   &
             &                                                       cd_type = cd_type, psgn   = psgn  , kfill = kfill,   &
-            &                                                       kstart  = kstart , kcount = kcount, ldxios=ldxios  )
+            &                                                       kstart  = kstart , kcount = kcount                )
          END IF
       ENDIF
@@ -1073,5 +1140,5 @@
 
    SUBROUTINE iom_get_123d( kiomid , kdom, cdvar, pv_r1d, pv_r2d, pv_r3d, ktime ,   &
-         &                  cd_type, psgn, kfill, kstart, kcount, ldxios )
+         &                  cd_type, psgn, kfill, kstart, kcount )
       !!-----------------------------------------------------------------------
       !!                  ***  ROUTINE  iom_get_123d  ***
@@ -1093,8 +1160,6 @@
       INTEGER , DIMENSION(:)     , INTENT(in   ), OPTIONAL ::   kstart    ! start position of the reading in each axis 
       INTEGER , DIMENSION(:)     , INTENT(in   ), OPTIONAL ::   kcount    ! number of points to be read in each axis
-      LOGICAL                    , INTENT(in   ), OPTIONAL ::   ldxios    ! use XIOS to read restart
       !
       LOGICAL                        ::   llok        ! true if ok!
-      LOGICAL                        ::   llxios      ! local definition for XIOS read
       INTEGER                        ::   jl          ! loop on number of dimension 
       INTEGER                        ::   idom        ! type of domain
@@ -1123,15 +1188,14 @@
       REAL(dp)                       ::   gma, gmi
       !---------------------------------------------------------------------
-      !
+      CHARACTER(LEN=lc)                               ::   context
+      !
+      CALL set_xios_context(kiomid, context)
       inlev = -1
       IF( PRESENT(pv_r3d) )   inlev = SIZE(pv_r3d, 3)
       !
-      llxios = .FALSE.
-      IF( PRESENT(ldxios) )   llxios = ldxios
-      !
       idom = kdom
       istop = nstop
       !
-      IF(.NOT.llxios) THEN
+      IF(context == "NONE") THEN
          clname = iom_file(kiomid)%name   !   esier to read
          clinfo = '          iom_get_123d, file: '//trim(clname)//', var: '//trim(cdvar)
@@ -1301,5 +1365,5 @@
 !would be good to be able to check which context is active and swap only if current is not restart
          idvar = iom_varid( kiomid, cdvar )
-
+         CALL iom_swap(context)
          zsgn = 1._wp
          IF( PRESENT(psgn   ) )   zsgn    = psgn
@@ -1323,4 +1387,5 @@
             CALL xios_recv_field( trim(cdvar), pv_r1d)
          ENDIF
+         CALL iom_swap(cxios_context)
 #else
          istop = istop + 1 
@@ -1518,5 +1583,5 @@
    !!                   INTERFACE iom_rstput
    !!----------------------------------------------------------------------
-   SUBROUTINE iom_rp0d_sp( kt, kwrite, kiomid, cdvar, pvar, ktype, ldxios )
+   SUBROUTINE iom_rp0d_sp( kt, kwrite, kiomid, cdvar, pvar, ktype )
       INTEGER         , INTENT(in)                         ::   kt       ! ocean time-step
       INTEGER         , INTENT(in)                         ::   kwrite   ! writing time-step
@@ -1525,19 +1590,26 @@
       REAL(sp)        , INTENT(in)                         ::   pvar     ! written field
       INTEGER         , INTENT(in), OPTIONAL               ::   ktype    ! variable external type
-      LOGICAL, OPTIONAL :: ldxios   ! xios write flag
-      LOGICAL :: llx                ! local xios write flag
-      INTEGER :: ivid   ! variable id
-
-      llx = .FALSE.
-      IF(PRESENT(ldxios)) llx = ldxios
+      !
+      LOGICAL           :: llx                ! local xios write flag
+      INTEGER           :: ivid   ! variable id
+      CHARACTER(LEN=lc) :: context
+      !
+      CALL set_xios_context(kiomid, context)
+
+      llx = .NOT. (context == "NONE")
+
       IF( llx ) THEN
 #ifdef key_iomput
-      IF( kt == kwrite ) THEN
-         IF(lwp) write(numout,*) 'RESTART: write (XIOS 0D) ',trim(cdvar)
-         CALL iom_put(trim(cdvar), pvar)
-      ELSE
-         IF(lwp) write(numout,*) 'RESTART: define (XIOS 0D) ',trim(cdvar)
-         CALL iom_set_rstw_active( trim(cdvar), rs0 = pvar ) 
-      ENDIF
+         IF( kt == kwrite ) THEN
+            IF(lwp) write(numout,*) 'RESTART: write (XIOS 0D) ',trim(cdvar)
+            CALL iom_swap(context)
+            CALL iom_put(trim(cdvar), pvar)
+            CALL iom_swap(cxios_context)
+         ELSE
+            IF(lwp) write(numout,*) 'RESTART: define (XIOS 0D) ',trim(cdvar)
+            CALL iom_swap(context)
+            CALL iom_set_rstw_active( trim(cdvar), rs0 = pvar ) 
+            CALL iom_swap(cxios_context)
+         ENDIF
 #endif
       ELSE
@@ -1551,5 +1623,5 @@
    END SUBROUTINE iom_rp0d_sp
 
-   SUBROUTINE iom_rp0d_dp( kt, kwrite, kiomid, cdvar, pvar, ktype, ldxios )
+   SUBROUTINE iom_rp0d_dp( kt, kwrite, kiomid, cdvar, pvar, ktype )
       INTEGER         , INTENT(in)                         ::   kt       ! ocean time-step
       INTEGER         , INTENT(in)                         ::   kwrite   ! writing time-step
@@ -1558,19 +1630,26 @@
       REAL(dp)        , INTENT(in)                         ::   pvar     ! written field
       INTEGER         , INTENT(in), OPTIONAL               ::   ktype    ! variable external type
-      LOGICAL, OPTIONAL :: ldxios   ! xios write flag
-      LOGICAL :: llx                ! local xios write flag
-      INTEGER :: ivid   ! variable id
-
-      llx = .FALSE.
-      IF(PRESENT(ldxios)) llx = ldxios
+      !
+      LOGICAL           :: llx                ! local xios write flag
+      INTEGER           :: ivid   ! variable id
+      CHARACTER(LEN=lc) :: context
+      !
+      CALL set_xios_context(kiomid, context)
+
+      llx = .NOT. (context == "NONE")
+
       IF( llx ) THEN
 #ifdef key_iomput
-      IF( kt == kwrite ) THEN
-         IF(lwp) write(numout,*) 'RESTART: write (XIOS 0D) ',trim(cdvar)
-         CALL iom_put(trim(cdvar), pvar)
-      ELSE
-         IF(lwp) write(numout,*) 'RESTART: define (XIOS 0D) ',trim(cdvar)
-         CALL iom_set_rstw_active( trim(cdvar), rd0 = pvar ) 
-      ENDIF
+         IF( kt == kwrite ) THEN
+            IF(lwp) write(numout,*) 'RESTART: write (XIOS 0D) ',trim(cdvar)
+            CALL iom_swap(context)
+            CALL iom_put(trim(cdvar), pvar)
+            CALL iom_swap(cxios_context)
+         ELSE
+            IF(lwp) write(numout,*) 'RESTART: define (XIOS 0D) ',trim(cdvar)
+            CALL iom_swap(context)
+            CALL iom_set_rstw_active( trim(cdvar), rd0 = pvar ) 
+            CALL iom_swap(cxios_context)
+         ENDIF
 #endif
       ELSE
@@ -1585,5 +1664,5 @@
 
 
-   SUBROUTINE iom_rp1d_sp( kt, kwrite, kiomid, cdvar, pvar, ktype, ldxios )
+   SUBROUTINE iom_rp1d_sp( kt, kwrite, kiomid, cdvar, pvar, ktype )
       INTEGER         , INTENT(in)                         ::   kt       ! ocean time-step
       INTEGER         , INTENT(in)                         ::   kwrite   ! writing time-step
@@ -1592,19 +1671,26 @@
       REAL(sp)        , INTENT(in), DIMENSION(          :) ::   pvar     ! written field
       INTEGER         , INTENT(in), OPTIONAL               ::   ktype    ! variable external type
-      LOGICAL, OPTIONAL                                    ::   ldxios   ! xios write flag
-      LOGICAL :: llx                ! local xios write flag
-      INTEGER :: ivid   ! variable id
-
-      llx = .FALSE.
-      IF(PRESENT(ldxios)) llx = ldxios
+      !
+      LOGICAL           :: llx                ! local xios write flag
+      INTEGER           :: ivid   ! variable id
+      CHARACTER(LEN=lc) :: context
+      !
+      CALL set_xios_context(kiomid, context)
+
+      llx = .NOT. (context == "NONE")
+
       IF( llx ) THEN
 #ifdef key_iomput
-      IF( kt == kwrite ) THEN
-         IF(lwp) write(numout,*) 'RESTART: write (XIOS 1D) ',trim(cdvar)
-         CALL iom_put(trim(cdvar), pvar)
-      ELSE
-         IF(lwp) write(numout,*) 'RESTART: define (XIOS 1D)',trim(cdvar)
-         CALL iom_set_rstw_active( trim(cdvar), rs1 = pvar )
-      ENDIF
+         IF( kt == kwrite ) THEN
+            IF(lwp) write(numout,*) 'RESTART: write (XIOS 1D) ',trim(cdvar)
+            CALL iom_swap(context)
+            CALL iom_put(trim(cdvar), pvar)
+            CALL iom_swap(cxios_context)
+         ELSE
+            IF(lwp) write(numout,*) 'RESTART: define (XIOS 1D)',trim(cdvar)
+            CALL iom_swap(context)
+            CALL iom_set_rstw_active( trim(cdvar), rs1 = pvar )
+            CALL iom_swap(cxios_context)
+         ENDIF
 #endif
       ELSE
@@ -1618,5 +1704,5 @@
    END SUBROUTINE iom_rp1d_sp
 
-   SUBROUTINE iom_rp1d_dp( kt, kwrite, kiomid, cdvar, pvar, ktype, ldxios )
+   SUBROUTINE iom_rp1d_dp( kt, kwrite, kiomid, cdvar, pvar, ktype )
       INTEGER         , INTENT(in)                         ::   kt       ! ocean time-step
       INTEGER         , INTENT(in)                         ::   kwrite   ! writing time-step
@@ -1625,19 +1711,26 @@
       REAL(dp)        , INTENT(in), DIMENSION(          :) ::   pvar     ! written field
       INTEGER         , INTENT(in), OPTIONAL               ::   ktype    ! variable external type
-      LOGICAL, OPTIONAL                                    ::   ldxios   ! xios write flag
-      LOGICAL :: llx                ! local xios write flag
-      INTEGER :: ivid   ! variable id
-
-      llx = .FALSE.
-      IF(PRESENT(ldxios)) llx = ldxios
+      !
+      LOGICAL           :: llx                ! local xios write flag
+      INTEGER           :: ivid   ! variable id
+      CHARACTER(LEN=lc) :: context
+      !
+      CALL set_xios_context(kiomid, context)
+
+      llx = .NOT. (context == "NONE")
+
       IF( llx ) THEN
 #ifdef key_iomput
-      IF( kt == kwrite ) THEN
-         IF(lwp) write(numout,*) 'RESTART: write (XIOS 1D) ',trim(cdvar)
-         CALL iom_put(trim(cdvar), pvar)
-      ELSE
-         IF(lwp) write(numout,*) 'RESTART: define (XIOS 1D)',trim(cdvar)
-         CALL iom_set_rstw_active( trim(cdvar), rd1 = pvar )
-      ENDIF
+         IF( kt == kwrite ) THEN
+            IF(lwp) write(numout,*) 'RESTART: write (XIOS 1D) ',trim(cdvar)
+            CALL iom_swap(context)
+            CALL iom_put(trim(cdvar), pvar)
+            CALL iom_swap(cxios_context)
+         ELSE
+            IF(lwp) write(numout,*) 'RESTART: define (XIOS 1D)',trim(cdvar)
+            CALL iom_swap(context)
+            CALL iom_set_rstw_active( trim(cdvar), rd1 = pvar )
+            CALL iom_swap(cxios_context)
+         ENDIF
 #endif
       ELSE
@@ -1652,5 +1745,5 @@
 
 
-   SUBROUTINE iom_rp2d_sp( kt, kwrite, kiomid, cdvar, pvar, ktype, ldxios )
+   SUBROUTINE iom_rp2d_sp( kt, kwrite, kiomid, cdvar, pvar, ktype )
       INTEGER         , INTENT(in)                         ::   kt       ! ocean time-step
       INTEGER         , INTENT(in)                         ::   kwrite   ! writing time-step
@@ -1659,19 +1752,26 @@
       REAL(sp)        , INTENT(in), DIMENSION(:,    :    ) ::   pvar     ! written field
       INTEGER         , INTENT(in), OPTIONAL               ::   ktype    ! variable external type
-      LOGICAL, OPTIONAL :: ldxios   ! xios write flag
-      LOGICAL :: llx
-      INTEGER :: ivid   ! variable id
-
-      llx = .FALSE.
-      IF(PRESENT(ldxios)) llx = ldxios
+      !
+      LOGICAL            :: llx
+      INTEGER            :: ivid   ! variable id
+      CHARACTER(LEN=lc)  :: context
+      !
+      CALL set_xios_context(kiomid, context)
+
+      llx = .NOT. (context == "NONE")
+
       IF( llx ) THEN
 #ifdef key_iomput
-      IF( kt == kwrite ) THEN
-         IF(lwp) write(numout,*) 'RESTART: write (XIOS 2D) ',trim(cdvar)
-         CALL iom_put(trim(cdvar), pvar)
-      ELSE
-         IF(lwp) write(numout,*) 'RESTART: define (XIOS 2D)',trim(cdvar)
-         CALL iom_set_rstw_active( trim(cdvar), rs2 = pvar )
-      ENDIF
+         IF( kt == kwrite ) THEN
+            IF(lwp) write(numout,*) 'RESTART: write (XIOS 2D) ',trim(cdvar)
+            CALL iom_swap(context)
+            CALL iom_put(trim(cdvar), pvar)
+            CALL iom_swap(cxios_context)
+         ELSE
+            IF(lwp) write(numout,*) 'RESTART: define (XIOS 2D)',trim(cdvar)
+            CALL iom_swap(context)
+            CALL iom_set_rstw_active( trim(cdvar), rs2 = pvar )
+            CALL iom_swap(cxios_context)
+         ENDIF
 #endif
       ELSE
@@ -1685,5 +1785,5 @@
    END SUBROUTINE iom_rp2d_sp
 
-   SUBROUTINE iom_rp2d_dp( kt, kwrite, kiomid, cdvar, pvar, ktype, ldxios )
+   SUBROUTINE iom_rp2d_dp( kt, kwrite, kiomid, cdvar, pvar, ktype )
       INTEGER         , INTENT(in)                         ::   kt       ! ocean time-step
       INTEGER         , INTENT(in)                         ::   kwrite   ! writing time-step
@@ -1692,19 +1792,26 @@
       REAL(dp)        , INTENT(in), DIMENSION(:,    :    ) ::   pvar     ! written field
       INTEGER         , INTENT(in), OPTIONAL               ::   ktype    ! variable external type
-      LOGICAL, OPTIONAL :: ldxios   ! xios write flag
-      LOGICAL :: llx
-      INTEGER :: ivid   ! variable id
-
-      llx = .FALSE.
-      IF(PRESENT(ldxios)) llx = ldxios
+      !
+      LOGICAL           :: llx
+      INTEGER           :: ivid   ! variable id
+      CHARACTER(LEN=lc) :: context
+      !
+      CALL set_xios_context(kiomid, context)
+
+      llx = .NOT. (context == "NONE")
+
       IF( llx ) THEN
 #ifdef key_iomput
-      IF( kt == kwrite ) THEN
-         IF(lwp) write(numout,*) 'RESTART: write (XIOS 2D) ',trim(cdvar)
-         CALL iom_put(trim(cdvar), pvar)
-      ELSE
-         IF(lwp) write(numout,*) 'RESTART: define (XIOS 2D)',trim(cdvar)
-         CALL iom_set_rstw_active( trim(cdvar), rd2 = pvar )
-      ENDIF
+         IF( kt == kwrite ) THEN
+            IF(lwp) write(numout,*) 'RESTART: write (XIOS 2D) ',trim(cdvar)
+            CALL iom_swap(context)
+            CALL iom_put(trim(cdvar), pvar)
+            CALL iom_swap(cxios_context)
+         ELSE
+            IF(lwp) write(numout,*) 'RESTART: define (XIOS 2D)',trim(cdvar)
+            CALL iom_swap(context)
+            CALL iom_set_rstw_active( trim(cdvar), rd2 = pvar )
+            CALL iom_swap(cxios_context)
+         ENDIF
 #endif
       ELSE
@@ -1719,5 +1826,5 @@
 
 
-   SUBROUTINE iom_rp3d_sp( kt, kwrite, kiomid, cdvar, pvar, ktype, ldxios )
+   SUBROUTINE iom_rp3d_sp( kt, kwrite, kiomid, cdvar, pvar, ktype )
       INTEGER         , INTENT(in)                         ::   kt       ! ocean time-step
       INTEGER         , INTENT(in)                         ::   kwrite   ! writing time-step
@@ -1726,19 +1833,26 @@
       REAL(sp)        , INTENT(in),       DIMENSION(:,:,:) ::   pvar     ! written field
       INTEGER         , INTENT(in), OPTIONAL               ::   ktype    ! variable external type
-      LOGICAL, OPTIONAL :: ldxios   ! xios write flag
-      LOGICAL :: llx                 ! local xios write flag
-      INTEGER :: ivid   ! variable id
-
-      llx = .FALSE.
-      IF(PRESENT(ldxios)) llx = ldxios
+      !
+      LOGICAL           :: llx                 ! local xios write flag
+      INTEGER           :: ivid   ! variable id
+      CHARACTER(LEN=lc) :: context
+      !
+      CALL set_xios_context(kiomid, context)
+
+      llx = .NOT. (context == "NONE")
+
       IF( llx ) THEN
 #ifdef key_iomput
-      IF( kt == kwrite ) THEN
-         IF(lwp) write(numout,*) 'RESTART: write (XIOS 3D) ',trim(cdvar)
-         CALL iom_put(trim(cdvar), pvar)
-      ELSE
-         IF(lwp) write(numout,*) 'RESTART: define (XIOS 3D)',trim(cdvar)
-         CALL iom_set_rstw_active( trim(cdvar), rs3 = pvar )
-      ENDIF
+         IF( kt == kwrite ) THEN
+            IF(lwp) write(numout,*) 'RESTART: write (XIOS 3D) ',trim(cdvar)
+            CALL iom_swap(context)
+            CALL iom_put(trim(cdvar), pvar)
+            CALL iom_swap(cxios_context)
+         ELSE
+            IF(lwp) write(numout,*) 'RESTART: define (XIOS 3D)',trim(cdvar)
+            CALL iom_swap(context)
+            CALL iom_set_rstw_active( trim(cdvar), rs3 = pvar )
+            CALL iom_swap(cxios_context)
+         ENDIF
 #endif
       ELSE
@@ -1752,5 +1866,5 @@
    END SUBROUTINE iom_rp3d_sp
 
-   SUBROUTINE iom_rp3d_dp( kt, kwrite, kiomid, cdvar, pvar, ktype, ldxios )
+   SUBROUTINE iom_rp3d_dp( kt, kwrite, kiomid, cdvar, pvar, ktype )
       INTEGER         , INTENT(in)                         ::   kt       ! ocean time-step
       INTEGER         , INTENT(in)                         ::   kwrite   ! writing time-step
@@ -1759,19 +1873,26 @@
       REAL(dp)        , INTENT(in),       DIMENSION(:,:,:) ::   pvar     ! written field
       INTEGER         , INTENT(in), OPTIONAL               ::   ktype    ! variable external type
-      LOGICAL, OPTIONAL :: ldxios   ! xios write flag
-      LOGICAL :: llx                 ! local xios write flag
-      INTEGER :: ivid   ! variable id
-
-      llx = .FALSE.
-      IF(PRESENT(ldxios)) llx = ldxios
+      !
+      LOGICAL           :: llx                 ! local xios write flag
+      INTEGER           :: ivid   ! variable id
+      CHARACTER(LEN=lc) :: context
+      !
+      CALL set_xios_context(kiomid, context)
+
+      llx = .NOT. (context == "NONE")
+
       IF( llx ) THEN
 #ifdef key_iomput
-      IF( kt == kwrite ) THEN
-         IF(lwp) write(numout,*) 'RESTART: write (XIOS 3D) ',trim(cdvar)
-         CALL iom_put(trim(cdvar), pvar)
-      ELSE
-         IF(lwp) write(numout,*) 'RESTART: define (XIOS 3D)',trim(cdvar)
-         CALL iom_set_rstw_active( trim(cdvar), rd3 = pvar )
-      ENDIF
+         IF( kt == kwrite ) THEN
+            IF(lwp) write(numout,*) 'RESTART: write (XIOS 3D) ',trim(cdvar)
+            CALL iom_swap(context)
+            CALL iom_put(trim(cdvar), pvar)
+            CALL iom_swap(cxios_context)
+         ELSE
+            IF(lwp) write(numout,*) 'RESTART: define (XIOS 3D)',trim(cdvar)
+            CALL iom_swap(context)
+            CALL iom_set_rstw_active( trim(cdvar), rd3 = pvar )
+            CALL iom_swap(cxios_context)
+         ENDIF
 #endif
       ELSE
Index: NEMO/branches/2020/dev_12905_xios_restart/src/OCE/IOM/restart.F90
===================================================================
--- NEMO/branches/2020/dev_12905_xios_restart/src/OCE/IOM/restart.F90	(revision 13931)
+++ NEMO/branches/2020/dev_12905_xios_restart/src/OCE/IOM/restart.F90	(revision 13932)
@@ -116,5 +116,6 @@
                   clpname = TRIM(Agrif_CFixed())//"_"//clname   
                ENDIF
-               CALL iom_init( cw_ocerst_cxt, fname = TRIM(clpath)//TRIM(clpname), ld_closedef = .false. )
+               numrow = iom_xios_setid(TRIM(clpath)//TRIM(clpname))
+               CALL iom_init( cw_ocerst_cxt, kdid = numrow, ld_closedef = .false. )
                CALL iom_swap(      cxios_context          )
 #else
@@ -142,25 +143,23 @@
       INTEGER, INTENT(in) ::   Kbb, Kmm   ! ocean time level indices
       !!----------------------------------------------------------------------
-                     IF(lwxios) CALL iom_swap(      cw_ocerst_cxt          )
-                     CALL iom_rstput( kt, nitrst, numrow, 'rdt'    , rn_Dt       , ldxios = lwxios)   ! dynamics time step
-                     CALL iom_delay_rst( 'WRITE', 'OCE', numrow )   ! save only ocean delayed global communication variables
+                     CALL iom_rstput( kt, nitrst, numrow, 'rdt'    , rn_Dt       )   ! dynamics time step
+                     IF(.NOT.lwxios) CALL iom_delay_rst( 'WRITE', 'OCE', numrow )   ! save only ocean delayed global communication variables
 
       IF ( .NOT. ln_diurnal_only ) THEN
-                     CALL iom_rstput( kt, nitrst, numrow, 'ub'     , uu(:,:,:       ,Kbb), ldxios = lwxios        )     ! before fields
-                     CALL iom_rstput( kt, nitrst, numrow, 'vb'     , vv(:,:,:       ,Kbb), ldxios = lwxios        )
-                     CALL iom_rstput( kt, nitrst, numrow, 'tb'     , ts(:,:,:,jp_tem,Kbb), ldxios = lwxios )
-                     CALL iom_rstput( kt, nitrst, numrow, 'sb'     , ts(:,:,:,jp_sal,Kbb), ldxios = lwxios )
-                     CALL iom_rstput( kt, nitrst, numrow, 'sshb'   ,ssh(:,:         ,Kbb), ldxios = lwxios      )
+                     CALL iom_rstput( kt, nitrst, numrow, 'ub'     , uu(:,:,:       ,Kbb) )     ! before fields
+                     CALL iom_rstput( kt, nitrst, numrow, 'vb'     , vv(:,:,:       ,Kbb) )
+                     CALL iom_rstput( kt, nitrst, numrow, 'tb'     , ts(:,:,:,jp_tem,Kbb) )
+                     CALL iom_rstput( kt, nitrst, numrow, 'sb'     , ts(:,:,:,jp_sal,Kbb) )
+                     CALL iom_rstput( kt, nitrst, numrow, 'sshb'   , ssh(:,:         ,Kbb))
                      !
-                     CALL iom_rstput( kt, nitrst, numrow, 'un'     , uu(:,:,:       ,Kmm), ldxios = lwxios        )     ! now fields
-                     CALL iom_rstput( kt, nitrst, numrow, 'vn'     , vv(:,:,:       ,Kmm), ldxios = lwxios        )
-                     CALL iom_rstput( kt, nitrst, numrow, 'tn'     , ts(:,:,:,jp_tem,Kmm), ldxios = lwxios )
-                     CALL iom_rstput( kt, nitrst, numrow, 'sn'     , ts(:,:,:,jp_sal,Kmm), ldxios = lwxios )
-                     CALL iom_rstput( kt, nitrst, numrow, 'sshn'   ,ssh(:,:         ,Kmm), ldxios = lwxios      )
-                     CALL iom_rstput( kt, nitrst, numrow, 'rhop'   , rhop, ldxios = lwxios      )
+                     CALL iom_rstput( kt, nitrst, numrow, 'un'     , uu(:,:,:       ,Kmm) )     ! now fields
+                     CALL iom_rstput( kt, nitrst, numrow, 'vn'     , vv(:,:,:       ,Kmm) )
+                     CALL iom_rstput( kt, nitrst, numrow, 'tn'     , ts(:,:,:,jp_tem,Kmm) )
+                     CALL iom_rstput( kt, nitrst, numrow, 'sn'     , ts(:,:,:,jp_sal,Kmm) )
+                     CALL iom_rstput( kt, nitrst, numrow, 'sshn'   , ssh(:,:         ,Kmm))
+                     CALL iom_rstput( kt, nitrst, numrow, 'rhop'   , rhop      )
       ENDIF
       
-      IF (ln_diurnal) CALL iom_rstput( kt, nitrst, numrow, 'Dsst', x_dsst, ldxios = lwxios )  
-      IF(lwxios) CALL iom_swap(      cxios_context          )
+      IF (ln_diurnal) CALL iom_rstput( kt, nitrst, numrow, 'Dsst', x_dsst )  
       IF( kt == nitrst ) THEN
          IF(.NOT.lwxios) THEN
@@ -168,4 +167,6 @@
          ELSE
             CALL iom_context_finalize(      cw_ocerst_cxt          )
+            iom_file(numrow)%nfid       = 0
+            numrow = 0
          ENDIF
 !!gm         IF( .NOT. lk_trdmld )   lrst_oce = .FALSE.
@@ -214,11 +215,11 @@
              cr_ocerst_cxt = 'oce_rst'
              IF(lwp) WRITE(numout,*) 'Enable restart reading by XIOS'
-             IF( TRIM(Agrif_CFixed()) == '0' ) THEN
-                clpname = cn_ocerst_in
-             ELSE
-                clpname = TRIM(Agrif_CFixed())//"_"//cn_ocerst_in   
-             ENDIF
-             CALL iom_init( cr_ocerst_cxt, fname = TRIM(clpath)//TRIM(clpname), &
-                              idfp = iom_file(numror)%nfid, ld_closedef = .TRUE. )
+!            IF( TRIM(Agrif_CFixed()) == '0' ) THEN
+!               clpname = cn_ocerst_in
+!            ELSE
+!               clpname = TRIM(Agrif_CFixed())//"_"//cn_ocerst_in   
+!            ENDIF
+             CALL iom_init( cr_ocerst_cxt, kdid = numror, ld_closedef = .TRUE. )
+             CALL iom_swap(      cxios_context          )
          ENDIF
 
@@ -245,7 +246,6 @@
 
       ! Check dynamics and tracer time-step consistency and force Euler restart if changed
-      IF( lrxios ) CALL iom_swap( cr_ocerst_cxt )
       IF( iom_varid( numror, 'rdt', ldstop = .FALSE. ) > 0 )   THEN
-         CALL iom_get( numror, 'rdt', zrdt, ldxios = lrxios )
+         CALL iom_get( numror, 'rdt', zrdt )
          IF( zrdt /= rn_Dt ) THEN
             IF(lwp) WRITE( numout,*)
@@ -257,13 +257,13 @@
       ENDIF
 
-      CALL iom_delay_rst( 'READ', 'OCE', numror )   ! read only ocean delayed global communication variables
+      IF(.NOT.lrxios ) CALL iom_delay_rst( 'READ', 'OCE', numror )   ! read only ocean delayed global communication variables
       
       ! Diurnal DSST 
-      IF( ln_diurnal ) CALL iom_get( numror, jpdom_auto, 'Dsst' , x_dsst, ldxios = lrxios ) 
+      IF( ln_diurnal ) CALL iom_get( numror, jpdom_auto, 'Dsst' , x_dsst ) 
       IF ( ln_diurnal_only ) THEN 
          IF(lwp) WRITE( numout, * ) &
          &   "rst_read:- ln_diurnal_only set, setting rhop=rho0" 
          rhop = rho0
-         CALL iom_get( numror, jpdom_auto, 'tn'     , w3d, ldxios = lrxios ) 
+         CALL iom_get( numror, jpdom_auto, 'tn'     , w3d ) 
          ts(:,:,1,jp_tem,Kmm) = w3d(:,:,1)
          RETURN 
@@ -272,9 +272,9 @@
       IF( iom_varid( numror, 'ub', ldstop = .FALSE. ) > 0 ) THEN
          ! before fields
-         CALL iom_get( numror, jpdom_auto, 'ub'     , uu(:,:,:       ,Kbb), ldxios = lrxios, cd_type = 'U', psgn = -1._wp )
-         CALL iom_get( numror, jpdom_auto, 'vb'     , vv(:,:,:       ,Kbb), ldxios = lrxios, cd_type = 'V', psgn = -1._wp )
-         CALL iom_get( numror, jpdom_auto, 'tb'     , ts(:,:,:,jp_tem,Kbb), ldxios = lrxios )
-         CALL iom_get( numror, jpdom_auto, 'sb'     , ts(:,:,:,jp_sal,Kbb), ldxios = lrxios )
-         CALL iom_get( numror, jpdom_auto, 'sshb'   ,ssh(:,:         ,Kbb), ldxios = lrxios )
+         CALL iom_get( numror, jpdom_auto, 'ub'     , uu(:,:,:       ,Kbb), cd_type = 'U', psgn = -1._wp )
+         CALL iom_get( numror, jpdom_auto, 'vb'     , vv(:,:,:       ,Kbb), cd_type = 'V', psgn = -1._wp )
+         CALL iom_get( numror, jpdom_auto, 'tb'     , ts(:,:,:,jp_tem,Kbb) )
+         CALL iom_get( numror, jpdom_auto, 'sb'     , ts(:,:,:,jp_sal,Kbb) )
+         CALL iom_get( numror, jpdom_auto, 'sshb'   ,ssh(:,:         ,Kbb) )
       ELSE
          l_1st_euler =  .TRUE.      ! before field not found, forced euler 1st time-step
@@ -282,15 +282,14 @@
       !
       ! now fields
-      CALL iom_get( numror, jpdom_auto, 'un'     , uu(:,:,:       ,Kmm), ldxios = lrxios, cd_type = 'U', psgn = -1._wp )
-      CALL iom_get( numror, jpdom_auto, 'vn'     , vv(:,:,:       ,Kmm), ldxios = lrxios, cd_type = 'V', psgn = -1._wp )
-      CALL iom_get( numror, jpdom_auto, 'tn'     , ts(:,:,:,jp_tem,Kmm), ldxios = lrxios )
-      CALL iom_get( numror, jpdom_auto, 'sn'     , ts(:,:,:,jp_sal,Kmm), ldxios = lrxios )
-      CALL iom_get( numror, jpdom_auto, 'sshn'   ,ssh(:,:         ,Kmm), ldxios = lrxios )
+      CALL iom_get( numror, jpdom_auto, 'un'     , uu(:,:,:       ,Kmm), cd_type = 'U', psgn = -1._wp )
+      CALL iom_get( numror, jpdom_auto, 'vn'     , vv(:,:,:       ,Kmm), cd_type = 'V', psgn = -1._wp )
+      CALL iom_get( numror, jpdom_auto, 'tn'     , ts(:,:,:,jp_tem,Kmm) )
+      CALL iom_get( numror, jpdom_auto, 'sn'     , ts(:,:,:,jp_sal,Kmm) )
+      CALL iom_get( numror, jpdom_auto, 'sshn'   ,ssh(:,:         ,Kmm) )
       IF( iom_varid( numror, 'rhop', ldstop = .FALSE. ) > 0 ) THEN
-         CALL iom_get( numror, jpdom_auto, 'rhop'   , rhop, ldxios = lrxios )   ! now    potential density
+         CALL iom_get( numror, jpdom_auto, 'rhop'   , rhop )   ! now    potential density
       ELSE
          CALL eos( ts(:,:,:,:,Kmm), rhd, rhop, gdept(:,:,:,Kmm) )   
       ENDIF
-      IF( lrxios ) CALL iom_swap( cxios_context )
       !
       IF( l_1st_euler ) THEN                                  ! Euler restart 
Index: NEMO/branches/2020/dev_12905_xios_restart/src/OCE/ISF/isfcpl.F90
===================================================================
--- NEMO/branches/2020/dev_12905_xios_restart/src/OCE/ISF/isfcpl.F90	(revision 13931)
+++ NEMO/branches/2020/dev_12905_xios_restart/src/OCE/ISF/isfcpl.F90	(revision 13932)
@@ -144,12 +144,10 @@
       END DO 
       !
-      IF( lwxios ) CALL iom_swap( cw_ocerst_cxt )
-      CALL iom_rstput( kt, nitrst, numrow, 'tmask'  , tmask , ldxios = lwxios )
-      CALL iom_rstput( kt, nitrst, numrow, 'ssmask' , ssmask, ldxios = lwxios )
-      CALL iom_rstput( kt, nitrst, numrow, 'e3t_n'  , ze3t , ldxios = lwxios )
-      CALL iom_rstput( kt, nitrst, numrow, 'e3u_n'  , ze3u , ldxios = lwxios )
-      CALL iom_rstput( kt, nitrst, numrow, 'e3v_n'  , ze3v , ldxios = lwxios )
-      CALL iom_rstput( kt, nitrst, numrow, 'gdepw_n', zgdepw , ldxios = lwxios )
-      IF( lwxios ) CALL iom_swap( cxios_context )
+      CALL iom_rstput( kt, nitrst, numrow, 'tmask'  , tmask  )
+      CALL iom_rstput( kt, nitrst, numrow, 'ssmask' , ssmask )
+      CALL iom_rstput( kt, nitrst, numrow, 'e3t_n'  , ze3t   )
+      CALL iom_rstput( kt, nitrst, numrow, 'e3u_n'  , ze3u   )
+      CALL iom_rstput( kt, nitrst, numrow, 'e3v_n'  , ze3v   )
+      CALL iom_rstput( kt, nitrst, numrow, 'gdepw_n', zgdepw )
       !
    END SUBROUTINE isfcpl_rst_write
@@ -174,7 +172,5 @@
       !!----------------------------------------------------------------------
       !
-      IF( lrxios ) CALL iom_swap( TRIM(cr_ocerst_cxt) )
-      CALL iom_get( numror, jpdom_auto, 'ssmask'  , zssmask_b, ldxios = lrxios   ) ! need to extrapolate T/S
-      IF( lrxios ) CALL iom_swap( TRIM(cxios_context) )
+      CALL iom_get( numror, jpdom_auto, 'ssmask'  , zssmask_b   ) ! need to extrapolate T/S
 
       ! compute new ssh if we open a full water column 
@@ -257,9 +253,7 @@
       !!----------------------------------------------------------------------
       ! 
-      IF( lrxios ) CALL iom_swap( TRIM(cr_ocerst_cxt) )
-      CALL iom_get( numror, jpdom_auto, 'tmask'  , ztmask_b, ldxios = lrxios   ) ! need to extrapolate T/S
-      !CALL iom_get( numror, jpdom_auto, 'wmask'  , zwmask_b, ldxios = lrxios   ) ! need to extrapolate T/S
-      !CALL iom_get( numror, jpdom_auto, 'gdepw_n', zdepw_b(:,:,:), ldxios = lrxios ) ! need to interpol vertical profile (vvl)
-      IF( lrxios ) CALL iom_swap( TRIM(cxios_context) )
+      CALL iom_get( numror, jpdom_auto, 'tmask'  , ztmask_b   ) ! need to extrapolate T/S
+      !CALL iom_get( numror, jpdom_auto, 'wmask'  , zwmask_b  ) ! need to extrapolate T/S
+      !CALL iom_get( numror, jpdom_auto, 'gdepw_n', zdepw_b(:,:,:) ) ! need to interpol vertical profile (vvl)
       !
       ! 
@@ -405,9 +399,7 @@
       !!----------------------------------------------------------------------
       !
-      IF( lrxios ) CALL iom_swap( TRIM(cr_ocerst_cxt) )
-      CALL iom_get( numror, jpdom_auto, 'tmask'  , ztmask_b, ldxios = lrxios )
-      CALL iom_get( numror, jpdom_auto, 'e3u_n'  , ze3u_b  , ldxios = lrxios )
-      CALL iom_get( numror, jpdom_auto, 'e3v_n'  , ze3v_b  , ldxios = lrxios )
-      IF( lrxios ) CALL iom_swap( TRIM(cxios_context) )
+      CALL iom_get( numror, jpdom_auto, 'tmask'  , ztmask_b )
+      CALL iom_get( numror, jpdom_auto, 'e3u_n'  , ze3u_b   )
+      CALL iom_get( numror, jpdom_auto, 'e3v_n'  , ze3v_b   )
       !
       ! 1.0: compute horizontal volume flux divergence difference before-after coupling
@@ -517,10 +509,8 @@
 
       ! get restart variable
-      IF( lrxios ) CALL iom_swap( TRIM(cr_ocerst_cxt) )
-      CALL iom_get( numror, jpdom_auto, 'tmask'  , ztmask_b(:,:,:), ldxios = lrxios   ) ! need to extrapolate T/S
-      CALL iom_get( numror, jpdom_auto, 'e3t_n'  , ze3t_b(:,:,:)  , ldxios = lrxios )
-      CALL iom_get( numror, jpdom_auto, 'tn'     , zt_b(:,:,:)    , ldxios = lrxios )
-      CALL iom_get( numror, jpdom_auto, 'sn'     , zs_b(:,:,:)    , ldxios = lrxios )
-      IF( lrxios ) CALL iom_swap( TRIM(cxios_context) )
+      CALL iom_get( numror, jpdom_auto, 'tmask'  , ztmask_b(:,:,:) ) ! need to extrapolate T/S
+      CALL iom_get( numror, jpdom_auto, 'e3t_n'  , ze3t_b(:,:,:)   )
+      CALL iom_get( numror, jpdom_auto, 'tn'     , zt_b(:,:,:)     )
+      CALL iom_get( numror, jpdom_auto, 'sn'     , zs_b(:,:,:)     )
 
       ! compute run length
Index: NEMO/branches/2020/dev_12905_xios_restart/src/OCE/ISF/isfrst.F90
===================================================================
--- NEMO/branches/2020/dev_12905_xios_restart/src/OCE/ISF/isfrst.F90	(revision 13931)
+++ NEMO/branches/2020/dev_12905_xios_restart/src/OCE/ISF/isfrst.F90	(revision 13932)
@@ -53,9 +53,7 @@
       IF( iom_varid( numror, cfwf_b, ldstop = .FALSE. ) > 0 ) THEN
          IF(lwp) WRITE(numout,*) '          nit000-1 isf tracer content forcing fields read in the restart file'
-         IF( lrxios ) CALL iom_swap( TRIM(cr_ocerst_cxt) )
-         CALL iom_get( numror, jpdom_auto, cfwf_b, pfwf_b(:,:)        , ldxios = lrxios )   ! before ice shelf melt
-         CALL iom_get( numror, jpdom_auto, chc_b , ptsc_b (:,:,jp_tem), ldxios = lrxios )   ! before ice shelf heat flux
-         CALL iom_get( numror, jpdom_auto, csc_b , ptsc_b (:,:,jp_sal), ldxios = lrxios )   ! before ice shelf heat flux
-         IF( lrxios ) CALL iom_swap( TRIM(cxios_context) )
+         CALL iom_get( numror, jpdom_auto, cfwf_b, pfwf_b(:,:)         )   ! before ice shelf melt
+         CALL iom_get( numror, jpdom_auto, chc_b , ptsc_b (:,:,jp_tem) )   ! before ice shelf heat flux
+         CALL iom_get( numror, jpdom_auto, csc_b , ptsc_b (:,:,jp_sal) )   ! before ice shelf heat flux
       ELSE
          pfwf_b(:,:)   = pfwf(:,:)
@@ -91,9 +89,7 @@
       !
       ! write restart variable
-      IF( lwxios ) CALL iom_swap( cw_ocerst_cxt )
-      CALL iom_rstput( kt, nitrst, numrow, cfwf_b, pfwf(:,:)       , ldxios = lwxios )
-      CALL iom_rstput( kt, nitrst, numrow, chc_b , ptsc(:,:,jp_tem), ldxios = lwxios )
-      CALL iom_rstput( kt, nitrst, numrow, csc_b , ptsc(:,:,jp_sal), ldxios = lwxios )
-      IF( lwxios ) CALL iom_swap( cxios_context )
+      CALL iom_rstput( kt, nitrst, numrow, cfwf_b, pfwf(:,:)        )
+      CALL iom_rstput( kt, nitrst, numrow, chc_b , ptsc(:,:,jp_tem) )
+      CALL iom_rstput( kt, nitrst, numrow, csc_b , ptsc(:,:,jp_sal) )
       !
    END SUBROUTINE isfrst_write
Index: NEMO/branches/2020/dev_12905_xios_restart/src/OCE/SBC/sbcapr.F90
===================================================================
--- NEMO/branches/2020/dev_12905_xios_restart/src/OCE/SBC/sbcapr.F90	(revision 13931)
+++ NEMO/branches/2020/dev_12905_xios_restart/src/OCE/SBC/sbcapr.F90	(revision 13932)
@@ -148,8 +148,7 @@
          !                                      ! ---------------------------------------- !
          !                                            !* Restart: read in restart file
-         IF( lrxios ) CALL iom_swap( TRIM(cr_ocerst_cxt) )
          IF( ln_rstart .AND. iom_varid( numror, 'ssh_ibb', ldstop = .FALSE. ) > 0 ) THEN 
             IF(lwp) WRITE(numout,*) 'sbc_apr:   ssh_ibb read in the restart file'
-            CALL iom_get( numror, jpdom_auto, 'ssh_ibb', ssh_ibb, ldxios = lrxios )   ! before inv. barometer ssh
+            CALL iom_get( numror, jpdom_auto, 'ssh_ibb', ssh_ibb )   ! before inv. barometer ssh
             !
          ELSE                                         !* no restart: set from nit000 values
@@ -157,5 +156,4 @@
             ssh_ibb(:,:) = ssh_ib(:,:)
          ENDIF
-         IF( lrxios ) CALL iom_swap( TRIM(cxios_context) )
       ENDIF
       !                                         ! ---------------------------------------- !
@@ -165,7 +163,5 @@
          IF(lwp) WRITE(numout,*) 'sbc_apr : ssh_ib written in ocean restart file at it= ', kt,' date= ', ndastp
          IF(lwp) WRITE(numout,*) '~~~~'
-         IF( lwxios ) CALL iom_swap(      cw_ocerst_cxt          )
-         CALL iom_rstput( kt, nitrst, numrow, 'ssh_ibb' , ssh_ib, ldxios = lwxios )
-         IF( lwxios ) CALL iom_swap(      cxios_context          )
+         CALL iom_rstput( kt, nitrst, numrow, 'ssh_ibb' , ssh_ib )
       ENDIF
       !
Index: NEMO/branches/2020/dev_12905_xios_restart/src/OCE/SBC/sbcmod.F90
===================================================================
--- NEMO/branches/2020/dev_12905_xios_restart/src/OCE/SBC/sbcmod.F90	(revision 13931)
+++ NEMO/branches/2020/dev_12905_xios_restart/src/OCE/SBC/sbcmod.F90	(revision 13932)
@@ -497,17 +497,16 @@
       IF( kt == nit000 ) THEN                          !   set the forcing field at nit000 - 1    !
          !                                             ! ---------------------------------------- !
-         IF( lrxios ) CALL iom_swap( TRIM(cr_ocerst_cxt) )
          IF( ln_rstart .AND.    &                               !* Restart: read in restart file
             & iom_varid( numror, 'utau_b', ldstop = .FALSE. ) > 0 ) THEN
             IF(lwp) WRITE(numout,*) '          nit000-1 surface forcing fields red in the restart file'
-            CALL iom_get( numror, jpdom_auto, 'utau_b', utau_b, ldxios = lrxios )   ! before i-stress  (U-point)
-            CALL iom_get( numror, jpdom_auto, 'vtau_b', vtau_b, ldxios = lrxios )   ! before j-stress  (V-point)
-            CALL iom_get( numror, jpdom_auto,  'qns_b',  qns_b, ldxios = lrxios )   ! before non solar heat flux (T-point)
+            CALL iom_get( numror, jpdom_auto, 'utau_b', utau_b )   ! before i-stress  (U-point)
+            CALL iom_get( numror, jpdom_auto, 'vtau_b', vtau_b )   ! before j-stress  (V-point)
+            CALL iom_get( numror, jpdom_auto,  'qns_b',  qns_b )   ! before non solar heat flux (T-point)
             ! The 3D heat content due to qsr forcing is treated in traqsr
-            ! CALL iom_get( numror, jpdom_auto, 'qsr_b' , qsr_b, ldxios = lrxios  ) ! before     solar heat flux (T-point)
-            CALL iom_get( numror, jpdom_auto, 'emp_b', emp_b, ldxios = lrxios  )    ! before     freshwater flux (T-point)
+            ! CALL iom_get( numror, jpdom_auto, 'qsr_b' , qsr_b  ) ! before     solar heat flux (T-point)
+            CALL iom_get( numror, jpdom_auto, 'emp_b', emp_b  )    ! before     freshwater flux (T-point)
             ! To ensure restart capability with 3.3x/3.4 restart files    !! to be removed in v3.6
             IF( iom_varid( numror, 'sfx_b', ldstop = .FALSE. ) > 0 ) THEN
-               CALL iom_get( numror, jpdom_auto, 'sfx_b', sfx_b, ldxios = lrxios )  ! before salt flux (T-point)
+               CALL iom_get( numror, jpdom_auto, 'sfx_b', sfx_b )  ! before salt flux (T-point)
             ELSE
                sfx_b (:,:) = sfx(:,:)
@@ -521,5 +520,4 @@
             sfx_b (:,:) = sfx (:,:)
          ENDIF
-         IF( lrxios ) CALL iom_swap( TRIM(cxios_context) )
       ENDIF
       !                                                ! ---------------------------------------- !
@@ -530,13 +528,11 @@
             &                    'at it= ', kt,' date= ', ndastp
          IF(lwp) WRITE(numout,*) '~~~~'
-         IF( lwxios ) CALL iom_swap(      cw_ocerst_cxt          )
-         CALL iom_rstput( kt, nitrst, numrow, 'utau_b' , utau, ldxios = lwxios )
-         CALL iom_rstput( kt, nitrst, numrow, 'vtau_b' , vtau, ldxios = lwxios )
-         CALL iom_rstput( kt, nitrst, numrow, 'qns_b'  , qns, ldxios = lwxios  )
+         CALL iom_rstput( kt, nitrst, numrow, 'utau_b' , utau )
+         CALL iom_rstput( kt, nitrst, numrow, 'vtau_b' , vtau )
+         CALL iom_rstput( kt, nitrst, numrow, 'qns_b'  , qns  )
          ! The 3D heat content due to qsr forcing is treated in traqsr
          ! CALL iom_rstput( kt, nitrst, numrow, 'qsr_b'  , qsr  )
-         CALL iom_rstput( kt, nitrst, numrow, 'emp_b'  , emp, ldxios = lwxios  )
-         CALL iom_rstput( kt, nitrst, numrow, 'sfx_b'  , sfx, ldxios = lwxios  )
-         IF( lwxios ) CALL iom_swap(      cxios_context          )
+         CALL iom_rstput( kt, nitrst, numrow, 'emp_b'  , emp  )
+         CALL iom_rstput( kt, nitrst, numrow, 'sfx_b'  , sfx  )
       ENDIF
       !                                                ! ---------------------------------------- !
Index: NEMO/branches/2020/dev_12905_xios_restart/src/OCE/SBC/sbcrnf.F90
===================================================================
--- NEMO/branches/2020/dev_12905_xios_restart/src/OCE/SBC/sbcrnf.F90	(revision 13931)
+++ NEMO/branches/2020/dev_12905_xios_restart/src/OCE/SBC/sbcrnf.F90	(revision 13932)
@@ -157,11 +157,10 @@
       IF( kt == nit000 ) THEN                          !   set the forcing field at nit000 - 1    !
          !                                             ! ---------------------------------------- !
-         IF( lrxios ) CALL iom_swap( TRIM(cr_ocerst_cxt) )
          IF( ln_rstart .AND.    &                               !* Restart: read in restart file
             & iom_varid( numror, 'rnf_b', ldstop = .FALSE. ) > 0 ) THEN
             IF(lwp) WRITE(numout,*) '          nit000-1 runoff forcing fields red in the restart file', lrxios
-            CALL iom_get( numror, jpdom_auto, 'rnf_b', rnf_b, ldxios = lrxios )     ! before runoff
-            CALL iom_get( numror, jpdom_auto, 'rnf_hc_b', rnf_tsc_b(:,:,jp_tem), ldxios = lrxios )   ! before heat content of runoff
-            CALL iom_get( numror, jpdom_auto, 'rnf_sc_b', rnf_tsc_b(:,:,jp_sal), ldxios = lrxios )   ! before salinity content of runoff
+            CALL iom_get( numror, jpdom_auto, 'rnf_b', rnf_b )     ! before runoff
+            CALL iom_get( numror, jpdom_auto, 'rnf_hc_b', rnf_tsc_b(:,:,jp_tem) )   ! before heat content of runoff
+            CALL iom_get( numror, jpdom_auto, 'rnf_sc_b', rnf_tsc_b(:,:,jp_sal) )   ! before salinity content of runoff
          ELSE                                                   !* no restart: set from nit000 values
             IF(lwp) WRITE(numout,*) '          nit000-1 runoff forcing fields set to nit000'
@@ -169,5 +168,4 @@
             rnf_tsc_b(:,:,:) = rnf_tsc(:,:,:)
          ENDIF
-         IF( lrxios ) CALL iom_swap( TRIM(cxios_context) )
       ENDIF
       !                                                ! ---------------------------------------- !
@@ -178,9 +176,7 @@
             &                    'at it= ', kt,' date= ', ndastp
          IF(lwp) WRITE(numout,*) '~~~~'
-         IF( lwxios ) CALL iom_swap(      cw_ocerst_cxt          )
-         CALL iom_rstput( kt, nitrst, numrow, 'rnf_b' , rnf, ldxios = lwxios )
-         CALL iom_rstput( kt, nitrst, numrow, 'rnf_hc_b', rnf_tsc(:,:,jp_tem), ldxios = lwxios )
-         CALL iom_rstput( kt, nitrst, numrow, 'rnf_sc_b', rnf_tsc(:,:,jp_sal), ldxios = lwxios )
-         IF( lwxios ) CALL iom_swap(      cxios_context          )
+         CALL iom_rstput( kt, nitrst, numrow, 'rnf_b' , rnf )
+         CALL iom_rstput( kt, nitrst, numrow, 'rnf_hc_b', rnf_tsc(:,:,jp_tem) )
+         CALL iom_rstput( kt, nitrst, numrow, 'rnf_sc_b', rnf_tsc(:,:,jp_sal) )
       ENDIF
       !
Index: NEMO/branches/2020/dev_12905_xios_restart/src/OCE/SBC/sbcssm.F90
===================================================================
--- NEMO/branches/2020/dev_12905_xios_restart/src/OCE/SBC/sbcssm.F90	(revision 13931)
+++ NEMO/branches/2020/dev_12905_xios_restart/src/OCE/SBC/sbcssm.F90	(revision 13932)
@@ -154,15 +154,13 @@
             IF(lwp) WRITE(numout,*) '~~~~~~~'
             zf_sbc = REAL( nn_fsbc, wp )
-            IF( lwxios ) CALL iom_swap(      cw_ocerst_cxt          )
-            CALL iom_rstput( kt, nitrst, numrow, 'nn_fsbc', zf_sbc, ldxios = lwxios )    ! sbc frequency
-            CALL iom_rstput( kt, nitrst, numrow, 'ssu_m'  , ssu_m, ldxios = lwxios  )    ! sea surface mean fields
-            CALL iom_rstput( kt, nitrst, numrow, 'ssv_m'  , ssv_m, ldxios = lwxios  )
-            CALL iom_rstput( kt, nitrst, numrow, 'sst_m'  , sst_m, ldxios = lwxios  )
-            CALL iom_rstput( kt, nitrst, numrow, 'sss_m'  , sss_m, ldxios = lwxios  )
-            CALL iom_rstput( kt, nitrst, numrow, 'ssh_m'  , ssh_m, ldxios = lwxios  )
-            CALL iom_rstput( kt, nitrst, numrow, 'e3t_m'  , e3t_m, ldxios = lwxios  )
-            CALL iom_rstput( kt, nitrst, numrow, 'frq_m'  , frq_m, ldxios = lwxios  )
-            !
-            IF( lwxios ) CALL iom_swap(      cxios_context          )
+            CALL iom_rstput( kt, nitrst, numrow, 'nn_fsbc', zf_sbc )    ! sbc frequency
+            CALL iom_rstput( kt, nitrst, numrow, 'ssu_m'  , ssu_m  )    ! sea surface mean fields
+            CALL iom_rstput( kt, nitrst, numrow, 'ssv_m'  , ssv_m  )
+            CALL iom_rstput( kt, nitrst, numrow, 'sst_m'  , sst_m  )
+            CALL iom_rstput( kt, nitrst, numrow, 'sss_m'  , sss_m  )
+            CALL iom_rstput( kt, nitrst, numrow, 'ssh_m'  , ssh_m  )
+            CALL iom_rstput( kt, nitrst, numrow, 'e3t_m'  , e3t_m  )
+            CALL iom_rstput( kt, nitrst, numrow, 'frq_m'  , frq_m  )
+            !
          ENDIF
          !
@@ -206,17 +204,16 @@
          IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~ '
          !
-         IF( lrxios ) CALL iom_swap( TRIM(cr_ocerst_cxt) )
          IF( ln_rstart .AND. iom_varid( numror, 'nn_fsbc', ldstop = .FALSE. ) > 0 ) THEN
             l_ssm_mean = .TRUE.
-            CALL iom_get( numror            , 'nn_fsbc', zf_sbc,ldxios = lrxios )     ! sbc frequency of previous run
-            CALL iom_get( numror, jpdom_auto, 'ssu_m'  , ssu_m, ldxios = lrxios, cd_type = 'U', psgn = -1._wp )    ! sea surface mean velocity    (U-point)
-            CALL iom_get( numror, jpdom_auto, 'ssv_m'  , ssv_m, ldxios = lrxios, cd_type = 'V', psgn = -1._wp )    !   "         "    velocity    (V-point)
-            CALL iom_get( numror, jpdom_auto, 'sst_m'  , sst_m, ldxios = lrxios )    !   "         "    temperature (T-point)
-            CALL iom_get( numror, jpdom_auto, 'sss_m'  , sss_m, ldxios = lrxios )    !   "         "    salinity    (T-point)
-            CALL iom_get( numror, jpdom_auto, 'ssh_m'  , ssh_m, ldxios = lrxios )    !   "         "    height      (T-point)
-            CALL iom_get( numror, jpdom_auto, 'e3t_m'  , e3t_m, ldxios = lrxios )    ! 1st level thickness          (T-point)
+            CALL iom_get( numror            , 'nn_fsbc', zf_sbc )     ! sbc frequency of previous run
+            CALL iom_get( numror, jpdom_auto, 'ssu_m'  , ssu_m, cd_type = 'U', psgn = -1._wp )    ! sea surface mean velocity    (U-point)
+            CALL iom_get( numror, jpdom_auto, 'ssv_m'  , ssv_m, cd_type = 'V', psgn = -1._wp )    !   "         "    velocity    (V-point)
+            CALL iom_get( numror, jpdom_auto, 'sst_m'  , sst_m )    !   "         "    temperature (T-point)
+            CALL iom_get( numror, jpdom_auto, 'sss_m'  , sss_m )    !   "         "    salinity    (T-point)
+            CALL iom_get( numror, jpdom_auto, 'ssh_m'  , ssh_m )    !   "         "    height      (T-point)
+            CALL iom_get( numror, jpdom_auto, 'e3t_m'  , e3t_m )    ! 1st level thickness          (T-point)
             ! fraction of solar net radiation absorbed in 1st T level
             IF( iom_varid( numror, 'frq_m', ldstop = .FALSE. ) > 0 ) THEN
-               CALL iom_get( numror, jpdom_auto, 'frq_m'  , frq_m, ldxios = lrxios  )
+               CALL iom_get( numror, jpdom_auto, 'frq_m'  , frq_m  )
             ELSE
                frq_m(:,:) = 1._wp   ! default definition
@@ -237,5 +234,4 @@
             ENDIF
          ENDIF
-         IF( lrxios ) CALL iom_swap( TRIM(cxios_context) )
       ENDIF
       !
Index: NEMO/branches/2020/dev_12905_xios_restart/src/OCE/TRA/traqsr.F90
===================================================================
--- NEMO/branches/2020/dev_12905_xios_restart/src/OCE/TRA/traqsr.F90	(revision 13931)
+++ NEMO/branches/2020/dev_12905_xios_restart/src/OCE/TRA/traqsr.F90	(revision 13932)
@@ -135,14 +135,12 @@
       !                         !-----------------------------------!
       IF( kt == nit000 ) THEN          !==  1st time step  ==!
-         IF( lrxios ) CALL iom_swap( TRIM(cr_ocerst_cxt) )
          IF( ln_rstart .AND. iom_varid( numror, 'qsr_hc_b', ldstop = .FALSE. ) > 0  .AND. .NOT.l_1st_euler ) THEN    ! read in restart
             IF(lwp) WRITE(numout,*) '          nit000-1 qsr tracer content forcing field read in the restart file'
             z1_2 = 0.5_wp
-            CALL iom_get( numror, jpdom_auto, 'qsr_hc_b', qsr_hc_b, ldxios = lrxios )   ! before heat content trend due to Qsr flux
+            CALL iom_get( numror, jpdom_auto, 'qsr_hc_b', qsr_hc_b )   ! before heat content trend due to Qsr flux
          ELSE                                           ! No restart or restart not found: Euler forward time stepping
             z1_2 = 1._wp
             qsr_hc_b(:,:,:) = 0._wp
          ENDIF
-         IF( lrxios ) CALL iom_swap( TRIM(cxios_context) )
       ELSE                             !==  Swap of qsr heat content  ==!
          z1_2 = 0.5_wp
@@ -294,8 +292,6 @@
       !
       IF( lrst_oce ) THEN     ! write in the ocean restart file
-         IF( lwxios ) CALL iom_swap(      cw_ocerst_cxt          )
-         CALL iom_rstput( kt, nitrst, numrow, 'qsr_hc_b'   , qsr_hc     , ldxios = lwxios )
-         CALL iom_rstput( kt, nitrst, numrow, 'fraqsr_1lev', fraqsr_1lev, ldxios = lwxios ) 
-         IF( lwxios ) CALL iom_swap(      cxios_context          )
+         CALL iom_rstput( kt, nitrst, numrow, 'qsr_hc_b'   , qsr_hc      )
+         CALL iom_rstput( kt, nitrst, numrow, 'fraqsr_1lev', fraqsr_1lev ) 
       ENDIF
       !
@@ -432,11 +428,9 @@
       !
       ! 1st ocean level attenuation coefficient (used in sbcssm)
-      IF( lrxios ) CALL iom_swap( TRIM(cr_ocerst_cxt) )
       IF( iom_varid( numror, 'fraqsr_1lev', ldstop = .FALSE. ) > 0 ) THEN
-         CALL iom_get( numror, jpdom_auto, 'fraqsr_1lev'  , fraqsr_1lev, ldxios = lrxios  )
+         CALL iom_get( numror, jpdom_auto, 'fraqsr_1lev'  , fraqsr_1lev  )
       ELSE
          fraqsr_1lev(:,:) = 1._wp   ! default : no penetration
       ENDIF
-      IF( lrxios ) CALL iom_swap( TRIM(cxios_context) )
       !
    END SUBROUTINE tra_qsr_init
Index: NEMO/branches/2020/dev_12905_xios_restart/src/OCE/TRA/trasbc.F90
===================================================================
--- NEMO/branches/2020/dev_12905_xios_restart/src/OCE/TRA/trasbc.F90	(revision 13931)
+++ NEMO/branches/2020/dev_12905_xios_restart/src/OCE/TRA/trasbc.F90	(revision 13932)
@@ -107,5 +107,4 @@
       !                             !==  Set before sbc tracer content fields  ==!
       IF( kt == nit000 ) THEN             !* 1st time-step
-         IF( lrxios ) CALL iom_swap( TRIM(cr_ocerst_cxt) )
          IF( ln_rstart .AND.    &               ! Restart: read in restart file
               & iom_varid( numror, 'sbc_hc_b', ldstop = .FALSE. ) > 0 ) THEN
@@ -113,6 +112,6 @@
             zfact = 0.5_wp
             sbc_tsc(:,:,:) = 0._wp
-            CALL iom_get( numror, jpdom_auto, 'sbc_hc_b', sbc_tsc_b(:,:,jp_tem), ldxios = lrxios )   ! before heat content sbc trend
-            CALL iom_get( numror, jpdom_auto, 'sbc_sc_b', sbc_tsc_b(:,:,jp_sal), ldxios = lrxios )   ! before salt content sbc trend
+            CALL iom_get( numror, jpdom_auto, 'sbc_hc_b', sbc_tsc_b(:,:,jp_tem) )   ! before heat content sbc trend
+            CALL iom_get( numror, jpdom_auto, 'sbc_sc_b', sbc_tsc_b(:,:,jp_sal) )   ! before salt content sbc trend
          ELSE                                   ! No restart or restart not found: Euler forward time stepping
             zfact = 1._wp
@@ -120,5 +119,4 @@
             sbc_tsc_b(:,:,:) = 0._wp
          ENDIF
-         IF( lrxios ) CALL iom_swap( TRIM(cxios_context) )
       ELSE                                !* other time-steps: swap of forcing fields
          zfact = 0.5_wp
@@ -147,8 +145,6 @@
       !                  
       IF( lrst_oce ) THEN           !==  write sbc_tsc in the ocean restart file  ==!
-         IF( lwxios ) CALL iom_swap(      cw_ocerst_cxt          )
-         CALL iom_rstput( kt, nitrst, numrow, 'sbc_hc_b', sbc_tsc(:,:,jp_tem), ldxios = lwxios )
-         CALL iom_rstput( kt, nitrst, numrow, 'sbc_sc_b', sbc_tsc(:,:,jp_sal), ldxios = lwxios )
-         IF( lwxios ) CALL iom_swap(      cxios_context          )
+         CALL iom_rstput( kt, nitrst, numrow, 'sbc_hc_b', sbc_tsc(:,:,jp_tem) )
+         CALL iom_rstput( kt, nitrst, numrow, 'sbc_sc_b', sbc_tsc(:,:,jp_sal) )
       ENDIF
       !
Index: NEMO/branches/2020/dev_12905_xios_restart/src/OCE/ZDF/zdfgls.F90
===================================================================
--- NEMO/branches/2020/dev_12905_xios_restart/src/OCE/ZDF/zdfgls.F90	(revision 13931)
+++ NEMO/branches/2020/dev_12905_xios_restart/src/OCE/ZDF/zdfgls.F90	(revision 13932)
@@ -1084,5 +1084,4 @@
          !                                   ! ---------------
          IF( ln_rstart ) THEN                   !* Read the restart file
-            IF( lrxios ) CALL iom_swap( TRIM(cr_ocerst_cxt) )
             id1 = iom_varid( numror, 'en'    , ldstop = .FALSE. )
             id2 = iom_varid( numror, 'avt_k' , ldstop = .FALSE. )
@@ -1091,8 +1090,8 @@
             !
             IF( MIN( id1, id2, id3, id4 ) > 0 ) THEN        ! all required arrays exist
-               CALL iom_get( numror, jpdom_auto, 'en'    , en    , ldxios = lrxios )
-               CALL iom_get( numror, jpdom_auto, 'avt_k' , avt_k , ldxios = lrxios )
-               CALL iom_get( numror, jpdom_auto, 'avm_k' , avm_k , ldxios = lrxios )
-               CALL iom_get( numror, jpdom_auto, 'hmxl_n', hmxl_n, ldxios = lrxios )
+               CALL iom_get( numror, jpdom_auto, 'en'    , en     )
+               CALL iom_get( numror, jpdom_auto, 'avt_k' , avt_k  )
+               CALL iom_get( numror, jpdom_auto, 'avm_k' , avm_k  )
+               CALL iom_get( numror, jpdom_auto, 'hmxl_n', hmxl_n )
             ELSE                        
                IF(lwp) WRITE(numout,*)
@@ -1102,5 +1101,4 @@
                ! avt_k, avm_k already set to the background value in zdf_phy_init
             ENDIF
-            IF( lrxios ) CALL iom_swap( TRIM(cxios_context) )
          ELSE                                   !* Start from rest
             IF(lwp) WRITE(numout,*)
@@ -1114,10 +1112,8 @@
          !                                   ! -------------------
          IF(lwp) WRITE(numout,*) '---- gls-rst ----'
-         IF( lwxios ) CALL iom_swap(      cw_ocerst_cxt         )
-         CALL iom_rstput( kt, nitrst, numrow, 'en'    , en    , ldxios = lwxios )
-         CALL iom_rstput( kt, nitrst, numrow, 'avt_k' , avt_k , ldxios = lwxios )
-         CALL iom_rstput( kt, nitrst, numrow, 'avm_k' , avm_k , ldxios = lwxios )
-         CALL iom_rstput( kt, nitrst, numrow, 'hmxl_n', hmxl_n, ldxios = lwxios )
-         IF( lwxios ) CALL iom_swap(      cxios_context          )
+         CALL iom_rstput( kt, nitrst, numrow, 'en'    , en     )
+         CALL iom_rstput( kt, nitrst, numrow, 'avt_k' , avt_k  )
+         CALL iom_rstput( kt, nitrst, numrow, 'avm_k' , avm_k  )
+         CALL iom_rstput( kt, nitrst, numrow, 'hmxl_n', hmxl_n )
          !
       ENDIF
Index: NEMO/branches/2020/dev_12905_xios_restart/src/OCE/ZDF/zdfosm.F90
===================================================================
--- NEMO/branches/2020/dev_12905_xios_restart/src/OCE/ZDF/zdfosm.F90	(revision 13931)
+++ NEMO/branches/2020/dev_12905_xios_restart/src/OCE/ZDF/zdfosm.F90	(revision 13932)
@@ -1467,8 +1467,7 @@
      !!-----------------------------------------------------------------------------
      IF( TRIM(cdrw) == 'READ'.AND. ln_rstart) THEN
-        IF( lrxios ) CALL iom_swap( TRIM(cr_ocerst_cxt) )
         id1 = iom_varid( numror, 'wn'   , ldstop = .FALSE. )
         IF( id1 > 0 ) THEN                       ! 'wn' exists; read
-           CALL iom_get( numror, jpdom_auto, 'wn', ww, ldxios = lrxios )
+           CALL iom_get( numror, jpdom_auto, 'wn', ww )
            WRITE(numout,*) ' ===>>>> :  ww read from restart file'
         ELSE
@@ -1479,13 +1478,11 @@
         id2 = iom_varid( numror, 'hbli'   , ldstop = .FALSE. )
         IF( id1 > 0 .AND. id2 > 0) THEN                       ! 'hbl' exists; read and return
-           CALL iom_get( numror, jpdom_auto, 'hbl' , hbl , ldxios = lrxios )
-           CALL iom_get( numror, jpdom_auto, 'hbli', hbli, ldxios = lrxios  )
+           CALL iom_get( numror, jpdom_auto, 'hbl' , hbl  )
+           CALL iom_get( numror, jpdom_auto, 'hbli', hbli  )
            WRITE(numout,*) ' ===>>>> :  hbl & hbli read from restart file'
-           IF( lrxios ) CALL iom_swap( TRIM(cxios_context) )
            RETURN
         ELSE                      ! 'hbl' & 'hbli' not in restart file, recalculate
            WRITE(numout,*) ' ===>>>> : previous run without osmosis scheme, hbl computed from stratification'
         END IF
-        IF( lrxios ) CALL iom_swap( TRIM(cxios_context) )
      END IF
 
@@ -1495,7 +1492,7 @@
      IF( TRIM(cdrw) == 'WRITE') THEN     !* Write hbli into the restart file, then return
         IF(lwp) WRITE(numout,*) '---- osm-rst ----'
-         CALL iom_rstput( kt, nitrst, numrow, 'wn'     , ww  , ldxios = lwxios )
-         CALL iom_rstput( kt, nitrst, numrow, 'hbl'    , hbl , ldxios = lwxios )
-         CALL iom_rstput( kt, nitrst, numrow, 'hbli'   , hbli, ldxios = lwxios )
+         CALL iom_rstput( kt, nitrst, numrow, 'wn'     , ww   )
+         CALL iom_rstput( kt, nitrst, numrow, 'hbl'    , hbl  )
+         CALL iom_rstput( kt, nitrst, numrow, 'hbli'   , hbli )
         RETURN
      END IF
Index: NEMO/branches/2020/dev_12905_xios_restart/src/OCE/ZDF/zdfric.F90
===================================================================
--- NEMO/branches/2020/dev_12905_xios_restart/src/OCE/ZDF/zdfric.F90	(revision 13931)
+++ NEMO/branches/2020/dev_12905_xios_restart/src/OCE/ZDF/zdfric.F90	(revision 13932)
@@ -206,13 +206,11 @@
          !           !* Read the restart file
          IF( ln_rstart ) THEN
-            IF( lrxios ) CALL iom_swap( TRIM(cr_ocerst_cxt) )
             id1 = iom_varid( numror, 'avt_k', ldstop = .FALSE. )
             id2 = iom_varid( numror, 'avm_k', ldstop = .FALSE. )
             !
             IF( MIN( id1, id2 ) > 0 ) THEN         ! restart exists => read it
-               CALL iom_get( numror, jpdom_auto, 'avt_k', avt_k, ldxios = lrxios )
-               CALL iom_get( numror, jpdom_auto, 'avm_k', avm_k, ldxios = lrxios )
+               CALL iom_get( numror, jpdom_auto, 'avt_k', avt_k )
+               CALL iom_get( numror, jpdom_auto, 'avm_k', avm_k )
             ENDIF
-            IF( lrxios ) CALL iom_swap( TRIM(cxios_context) )
          ENDIF
          !           !* otherwise Kz already set to the background value in zdf_phy_init
@@ -221,8 +219,6 @@
          !                                   ! -------------------
          IF(lwp) WRITE(numout,*) '---- ric-rst ----'
-         IF( lwxios ) CALL iom_swap(      cw_ocerst_cxt          )
-         CALL iom_rstput( kt, nitrst, numrow, 'avt_k', avt_k, ldxios = lwxios )
-         CALL iom_rstput( kt, nitrst, numrow, 'avm_k', avm_k, ldxios = lwxios)
-         IF( lwxios ) CALL iom_swap(      cxios_context          )
+         CALL iom_rstput( kt, nitrst, numrow, 'avt_k', avt_k )
+         CALL iom_rstput( kt, nitrst, numrow, 'avm_k', avm_k)
          !
       ENDIF
Index: NEMO/branches/2020/dev_12905_xios_restart/src/OCE/ZDF/zdftke.F90
===================================================================
--- NEMO/branches/2020/dev_12905_xios_restart/src/OCE/ZDF/zdftke.F90	(revision 13931)
+++ NEMO/branches/2020/dev_12905_xios_restart/src/OCE/ZDF/zdftke.F90	(revision 13932)
@@ -746,5 +746,4 @@
          !                                   ! ---------------
          IF( ln_rstart ) THEN                   !* Read the restart file
-            IF( lrxios ) CALL iom_swap( TRIM(cr_ocerst_cxt) )
             id1 = iom_varid( numror, 'en'   , ldstop = .FALSE. )
             id2 = iom_varid( numror, 'avt_k', ldstop = .FALSE. )
@@ -753,8 +752,8 @@
             !
             IF( MIN( id1, id2, id3, id4 ) > 0 ) THEN      ! fields exist
-               CALL iom_get( numror, jpdom_auto, 'en'   , en   , ldxios = lrxios )
-               CALL iom_get( numror, jpdom_auto, 'avt_k', avt_k, ldxios = lrxios )
-               CALL iom_get( numror, jpdom_auto, 'avm_k', avm_k, ldxios = lrxios )
-               CALL iom_get( numror, jpdom_auto, 'dissl', dissl, ldxios = lrxios )
+               CALL iom_get( numror, jpdom_auto, 'en'   , en    )
+               CALL iom_get( numror, jpdom_auto, 'avt_k', avt_k )
+               CALL iom_get( numror, jpdom_auto, 'avm_k', avm_k )
+               CALL iom_get( numror, jpdom_auto, 'dissl', dissl )
             ELSE                                          ! start TKE from rest
                IF(lwp) WRITE(numout,*)
@@ -764,5 +763,4 @@
                ! avt_k, avm_k already set to the background value in zdf_phy_init
             ENDIF
-            IF( lrxios ) CALL iom_swap( TRIM(cxios_context) )
          ELSE                                   !* Start from rest
             IF(lwp) WRITE(numout,*)
@@ -776,10 +774,8 @@
          !                                   ! -------------------
          IF(lwp) WRITE(numout,*) '---- tke_rst ----'
-         IF( lwxios ) CALL iom_swap(      cw_ocerst_cxt          ) 
-         CALL iom_rstput( kt, nitrst, numrow, 'en'   , en   , ldxios = lwxios )
-         CALL iom_rstput( kt, nitrst, numrow, 'avt_k', avt_k, ldxios = lwxios )
-         CALL iom_rstput( kt, nitrst, numrow, 'avm_k', avm_k, ldxios = lwxios )
-         CALL iom_rstput( kt, nitrst, numrow, 'dissl', dissl, ldxios = lwxios )
-         IF( lwxios ) CALL iom_swap(      cxios_context          )
+         CALL iom_rstput( kt, nitrst, numrow, 'en'   , en    )
+         CALL iom_rstput( kt, nitrst, numrow, 'avt_k', avt_k )
+         CALL iom_rstput( kt, nitrst, numrow, 'avm_k', avm_k )
+         CALL iom_rstput( kt, nitrst, numrow, 'dissl', dissl )
          !
       ENDIF
Index: NEMO/branches/2020/dev_12905_xios_restart/src/OCE/step.F90
===================================================================
--- NEMO/branches/2020/dev_12905_xios_restart/src/OCE/step.F90	(revision 13931)
+++ NEMO/branches/2020/dev_12905_xios_restart/src/OCE/step.F90	(revision 13932)
@@ -355,5 +355,5 @@
       IF( kstp == nit000 ) THEN                          ! 1st time step only
                                         CALL iom_close( numror )   ! close input  ocean restart file
-         IF( lrxios )                  CALL iom_context_finalize(      cr_ocerst_cxt         )
+         IF( lrxios )                   CALL iom_context_finalize(      cr_ocerst_cxt         )
          IF(lwm)                        CALL FLUSH    ( numond )   ! flush output namelist oce
          IF(lwm .AND. numoni /= -1 )    CALL FLUSH    ( numoni )   ! flush output namelist ice (if exist)
Index: NEMO/branches/2020/dev_12905_xios_restart/src/OFF/dtadyn.F90
===================================================================
--- NEMO/branches/2020/dev_12905_xios_restart/src/OFF/dtadyn.F90	(revision 13931)
+++ NEMO/branches/2020/dev_12905_xios_restart/src/OFF/dtadyn.F90	(revision 13932)
@@ -46,5 +46,5 @@
    USE fldread         ! read input fields 
    USE timing          ! Timing
-   USE trc, ONLY : ln_rsttr, numrtr, numrtw, lrst_trc
+   USE trc, ONLY : ln_rsttr, lrst_trc
 
    IMPLICIT NONE
Index: NEMO/branches/2020/dev_12905_xios_restart/src/SAS/step.F90
===================================================================
--- NEMO/branches/2020/dev_12905_xios_restart/src/SAS/step.F90	(revision 13931)
+++ NEMO/branches/2020/dev_12905_xios_restart/src/SAS/step.F90	(revision 13932)
@@ -162,4 +162,6 @@
          ELSE
             CALL iom_context_finalize( cw_ocerst_cxt )
+            iom_file(numrow)%nfid       = 0
+            numrow = 0
          ENDIF
          lrst_oce = .FALSE.
Index: NEMO/branches/2020/dev_12905_xios_restart/src/SWE/domvvl.F90
===================================================================
--- NEMO/branches/2020/dev_12905_xios_restart/src/SWE/domvvl.F90	(revision 13931)
+++ NEMO/branches/2020/dev_12905_xios_restart/src/SWE/domvvl.F90	(revision 13932)
@@ -1105,5 +1105,5 @@
          IF( ln_rstart ) THEN                   !* Read the restart file
             CALL rst_read_open                  !  open the restart file if necessary
-            CALL iom_get( numror, jpdom_auto, 'sshn'   , ssh(:,:,Kmm), ldxios = lrxios    )
+            CALL iom_get( numror, jpdom_auto, 'sshn'   , ssh(:,:,Kmm)    )
             !
             id1 = iom_varid( numror, 'e3t_b', ldstop = .FALSE. )
@@ -1118,6 +1118,6 @@
             !
             IF( MIN( id1, id2 ) > 0 ) THEN       ! all required arrays exist
-               CALL iom_get( numror, jpdom_auto, 'e3t_b', e3t(:,:,:,Kbb), ldxios = lrxios )
-               CALL iom_get( numror, jpdom_auto, 'e3t_n', e3t(:,:,:,Kmm), ldxios = lrxios )
+               CALL iom_get( numror, jpdom_auto, 'e3t_b', e3t(:,:,:,Kbb) )
+               CALL iom_get( numror, jpdom_auto, 'e3t_n', e3t(:,:,:,Kmm) )
                ! needed to restart if land processor not computed 
                IF(lwp) write(numout,*) 'dom_vvl_rst : e3t(:,:,:,Kbb) and e3t(:,:,:,Kmm) found in restart files'
@@ -1133,5 +1133,5 @@
                IF(lwp) write(numout,*) 'e3t_n set equal to e3t_b.'
                IF(lwp) write(numout,*) 'l_1st_euler is forced to true'
-               CALL iom_get( numror, jpdom_auto, 'e3t_b', e3t(:,:,:,Kbb), ldxios = lrxios )
+               CALL iom_get( numror, jpdom_auto, 'e3t_b', e3t(:,:,:,Kbb) )
                e3t(:,:,:,Kmm) = e3t(:,:,:,Kbb)
                l_1st_euler = .true.
@@ -1140,5 +1140,5 @@
                IF(lwp) write(numout,*) 'e3t_b set equal to e3t_n.'
                IF(lwp) write(numout,*) 'l_1st_euler is forced to true'
-               CALL iom_get( numror, jpdom_auto, 'e3t_n', e3t(:,:,:,Kmm), ldxios = lrxios )
+               CALL iom_get( numror, jpdom_auto, 'e3t_n', e3t(:,:,:,Kmm) )
                e3t(:,:,:,Kbb) = e3t(:,:,:,Kmm)
                l_1st_euler = .true.
@@ -1165,6 +1165,6 @@
                !                          ! ----------------------- !
                IF( MIN( id3, id4 ) > 0 ) THEN  ! all required arrays exist
-                  CALL iom_get( numror, jpdom_auto, 'tilde_e3t_b', tilde_e3t_b(:,:,:), ldxios = lrxios )
-                  CALL iom_get( numror, jpdom_auto, 'tilde_e3t_n', tilde_e3t_n(:,:,:), ldxios = lrxios )
+                  CALL iom_get( numror, jpdom_auto, 'tilde_e3t_b', tilde_e3t_b(:,:,:) )
+                  CALL iom_get( numror, jpdom_auto, 'tilde_e3t_n', tilde_e3t_n(:,:,:) )
                ELSE                            ! one at least array is missing
                   tilde_e3t_b(:,:,:) = 0.0_wp
@@ -1175,5 +1175,5 @@
                   !                       ! ------------ !
                   IF( id5 > 0 ) THEN  ! required array exists
-                     CALL iom_get( numror, jpdom_auto, 'hdiv_lf', hdiv_lf(:,:,:), ldxios = lrxios )
+                     CALL iom_get( numror, jpdom_auto, 'hdiv_lf', hdiv_lf(:,:,:) )
                   ELSE                ! array is missing
                      hdiv_lf(:,:,:) = 0.0_wp
@@ -1251,23 +1251,21 @@
          !                                   ! ===================
          IF(lwp) WRITE(numout,*) '---- dom_vvl_rst ----'
-         IF( lwxios ) CALL iom_swap(      cw_ocerst_cxt          )
          !                                           ! --------- !
          !                                           ! all cases !
          !                                           ! --------- !
-         CALL iom_rstput( kt, nitrst, numrow, 'e3t_b', e3t(:,:,:,Kbb), ldxios = lwxios )
-         CALL iom_rstput( kt, nitrst, numrow, 'e3t_n', e3t(:,:,:,Kmm), ldxios = lwxios )
+         CALL iom_rstput( kt, nitrst, numrow, 'e3t_b', e3t(:,:,:,Kbb) )
+         CALL iom_rstput( kt, nitrst, numrow, 'e3t_n', e3t(:,:,:,Kmm) )
          !                                           ! ----------------------- !
          IF( ln_vvl_ztilde .OR. ln_vvl_layer ) THEN  ! z_tilde and layer cases !
             !                                        ! ----------------------- !
-            CALL iom_rstput( kt, nitrst, numrow, 'tilde_e3t_b', tilde_e3t_b(:,:,:), ldxios = lwxios)
-            CALL iom_rstput( kt, nitrst, numrow, 'tilde_e3t_n', tilde_e3t_n(:,:,:), ldxios = lwxios)
+            CALL iom_rstput( kt, nitrst, numrow, 'tilde_e3t_b', tilde_e3t_b(:,:,:))
+            CALL iom_rstput( kt, nitrst, numrow, 'tilde_e3t_n', tilde_e3t_n(:,:,:))
          END IF
          !                                           ! -------------!    
          IF( ln_vvl_ztilde ) THEN                    ! z_tilde case !
             !                                        ! ------------ !
-            CALL iom_rstput( kt, nitrst, numrow, 'hdiv_lf', hdiv_lf(:,:,:), ldxios = lwxios)
+            CALL iom_rstput( kt, nitrst, numrow, 'hdiv_lf', hdiv_lf(:,:,:))
          ENDIF
          !
-         IF( lwxios ) CALL iom_swap(      cxios_context          )
       ENDIF
       !
Index: NEMO/branches/2020/dev_12905_xios_restart/src/TOP/C14/trcini_c14.F90
===================================================================
--- NEMO/branches/2020/dev_12905_xios_restart/src/TOP/C14/trcini_c14.F90	(revision 13931)
+++ NEMO/branches/2020/dev_12905_xios_restart/src/TOP/C14/trcini_c14.F90	(revision 13932)
@@ -68,11 +68,9 @@
         IF(lwp) WRITE(numout,*) ' ~~~~~~~~~~~~~~'
         ! 
-        IF(lrxios) CALL iom_swap(cr_toprst_cxt)
-        CALL iom_get( numrtr, 'co2sbc', co2sbc, ldxios = lrxios ) 
-        CALL iom_get( numrtr, jpdom_auto, 'c14sbc', c14sbc, ldxios = lrxios ) 
-        CALL iom_get( numrtr, jpdom_auto, 'exch_co2', exch_co2, ldxios = lrxios ) 
-        CALL iom_get( numrtr, jpdom_auto, 'exch_c14', exch_c14, ldxios = lrxios ) 
-        CALL iom_get( numrtr, jpdom_auto, 'qtr_c14', qtr_c14, ldxios = lrxios )
-        IF(lrxios) CALL iom_swap(cxios_context)
+        CALL iom_get( numrtr, 'co2sbc', co2sbc ) 
+        CALL iom_get( numrtr, jpdom_auto, 'c14sbc', c14sbc ) 
+        CALL iom_get( numrtr, jpdom_auto, 'exch_co2', exch_co2 ) 
+        CALL iom_get( numrtr, jpdom_auto, 'exch_c14', exch_c14 ) 
+        CALL iom_get( numrtr, jpdom_auto, 'qtr_c14', qtr_c14 )
         !
       END IF
@@ -87,7 +85,5 @@
       ELSE
         !
-        IF(lrxios) CALL iom_swap(cr_toprst_cxt)
-        CALL iom_get( numrtr, jpdom_auto, 'qint_c14', qint_c14, ldxios = lrxios ) 
-        IF(lrxios) CALL iom_swap(cxios_context)
+        CALL iom_get( numrtr, jpdom_auto, 'qint_c14', qint_c14 ) 
         !
       ENDIF
Index: NEMO/branches/2020/dev_12905_xios_restart/src/TOP/C14/trcsms_c14.F90
===================================================================
--- NEMO/branches/2020/dev_12905_xios_restart/src/TOP/C14/trcsms_c14.F90	(revision 13931)
+++ NEMO/branches/2020/dev_12905_xios_restart/src/TOP/C14/trcsms_c14.F90	(revision 13932)
@@ -144,12 +144,10 @@
          IF(lwp) WRITE(numout,*) ' ~~~~~~~~~~~~~~'
          !
-         IF( lwxios ) CALL iom_swap(      cw_toprst_cxt         )
-         CALL iom_rstput( kt, nitrst, numrtw, 'co2sbc', co2sbc,     ldxios = lwxios ) ! These five need      &
-         CALL iom_rstput( kt, nitrst, numrtw, 'c14sbc', c14sbc,     ldxios = lwxios ) ! &    to be written   &
-         CALL iom_rstput( kt, nitrst, numrtw, 'exch_co2', exch_co2, ldxios = lwxios ) ! &    for temporal    &
-         CALL iom_rstput( kt, nitrst, numrtw, 'exch_c14', exch_c14, ldxios = lwxios ) ! &    averages        &
-         CALL iom_rstput( kt, nitrst, numrtw, 'qtr_c14', qtr_c14,   ldxios = lwxios ) ! &    to be coherent.
-         CALL iom_rstput( kt, nitrst, numrtw, 'qint_c14', qint_c14, ldxios = lwxios ) ! Cumulative
-         IF( lwxios ) CALL iom_swap(      cxios_context         )
+         CALL iom_rstput( kt, nitrst, numrtw, 'co2sbc', co2sbc ) ! These five need      &
+         CALL iom_rstput( kt, nitrst, numrtw, 'c14sbc', c14sbc ) ! &    to be written   &
+         CALL iom_rstput( kt, nitrst, numrtw, 'exch_co2', exch_co2 ) ! &    for temporal    &
+         CALL iom_rstput( kt, nitrst, numrtw, 'exch_c14', exch_c14 ) ! &    averages        &
+         CALL iom_rstput( kt, nitrst, numrtw, 'qtr_c14', qtr_c14   ) ! &    to be coherent.
+         CALL iom_rstput( kt, nitrst, numrtw, 'qint_c14', qint_c14 ) ! Cumulative
          !
       ENDIF
Index: NEMO/branches/2020/dev_12905_xios_restart/src/TOP/CFC/trcsms_cfc.F90
===================================================================
--- NEMO/branches/2020/dev_12905_xios_restart/src/TOP/CFC/trcsms_cfc.F90	(revision 13931)
+++ NEMO/branches/2020/dev_12905_xios_restart/src/TOP/CFC/trcsms_cfc.F90	(revision 13932)
@@ -179,10 +179,8 @@
          IF(lwp) WRITE(numout,*) '~~~~'
          jl = 0
-         IF( lwxios ) CALL iom_swap(      cw_toprst_cxt         )
          DO jn = jp_cfc0, jp_cfc1
              jl = jl + 1
-            CALL iom_rstput( kt, nitrst, numrtw, 'qint_'//ctrcnm(jn), qint_cfc(:,:,jl), ldxios = lwxios )
+            CALL iom_rstput( kt, nitrst, numrtw, 'qint_'//ctrcnm(jn), qint_cfc(:,:,jl) )
          END DO
-         IF( lwxios ) CALL iom_swap(      cxios_context         )
       ENDIF                                            
       !
@@ -298,10 +296,8 @@
          !
          jl = 0
-         IF(lrxios) CALL iom_swap(cr_toprst_cxt)
          DO jn = jp_cfc0, jp_cfc1
             jl = jl + 1
-            CALL iom_get( numrtr, jpdom_auto, 'qint_'//ctrcnm(jn), qint_cfc(:,:,jl), ldxios = lrxios ) 
+            CALL iom_get( numrtr, jpdom_auto, 'qint_'//ctrcnm(jn), qint_cfc(:,:,jl) ) 
          END DO
-         IF(lrxios) CALL iom_swap(cxios_context)
       ENDIF
       IF(lwp) WRITE(numout,*)
Index: NEMO/branches/2020/dev_12905_xios_restart/src/TOP/PISCES/P2Z/p2zexp.F90
===================================================================
--- NEMO/branches/2020/dev_12905_xios_restart/src/TOP/PISCES/P2Z/p2zexp.F90	(revision 13931)
+++ NEMO/branches/2020/dev_12905_xios_restart/src/TOP/PISCES/P2Z/p2zexp.F90	(revision 13932)
@@ -134,8 +134,6 @@
             &                    'at it= ', kt,' date= ', ndastp
          IF(lwp) WRITE(numout,*) '~~~~'
-         IF( lwxios ) CALL iom_swap(      cw_toprst_cxt         )
-         CALL iom_rstput( kt, nitrst, numrtw, 'SEDB'//ctrcnm(jpdet), sedpocb(:,:), ldxios = lwxios )
-         CALL iom_rstput( kt, nitrst, numrtw, 'SEDN'//ctrcnm(jpdet), sedpocn(:,:), ldxios = lwxios )
-         IF( lwxios ) CALL iom_swap(      cxios_context         )
+         CALL iom_rstput( kt, nitrst, numrtw, 'SEDB'//ctrcnm(jpdet), sedpocb(:,:) )
+         CALL iom_rstput( kt, nitrst, numrtw, 'SEDN'//ctrcnm(jpdet), sedpocn(:,:) )
       ENDIF
       !
@@ -216,8 +214,6 @@
       !
       IF( ln_rsttr ) THEN
-         IF(lrxios) CALL iom_swap(cr_toprst_cxt)
-         CALL iom_get( numrtr, jpdom_auto, 'SEDB'//ctrcnm(jpdet), sedpocb(:,:), ldxios = lrxios )
-         CALL iom_get( numrtr, jpdom_auto, 'SEDN'//ctrcnm(jpdet), sedpocn(:,:), ldxios = lrxios )
-         IF(lrxios) CALL iom_swap(cxios_context)
+         CALL iom_get( numrtr, jpdom_auto, 'SEDB'//ctrcnm(jpdet), sedpocb(:,:) )
+         CALL iom_get( numrtr, jpdom_auto, 'SEDN'//ctrcnm(jpdet), sedpocn(:,:) )
       ELSE
          sedpocb(:,:) = 0._wp
Index: NEMO/branches/2020/dev_12905_xios_restart/src/TOP/PISCES/P4Z/p4zsms.F90
===================================================================
--- NEMO/branches/2020/dev_12905_xios_restart/src/TOP/PISCES/P4Z/p4zsms.F90	(revision 13931)
+++ NEMO/branches/2020/dev_12905_xios_restart/src/TOP/PISCES/P4Z/p4zsms.F90	(revision 13932)
@@ -332,14 +332,13 @@
          IF(lwp) WRITE(numout,*) ' ~~~~~~~~~~~~~~'
          ! 
-         IF(lrxios) CALL iom_swap(cr_toprst_cxt)
          IF( iom_varid( numrtr, 'PH', ldstop = .FALSE. ) > 0 ) THEN
-            CALL iom_get( numrtr, jpdom_auto, 'PH' , hi(:,:,:), ldxios = lrxios  )
+            CALL iom_get( numrtr, jpdom_auto, 'PH' , hi(:,:,:)  )
          ELSE
             CALL p4z_che( Kbb, Kmm )                  ! initialize the chemical constants
             CALL ahini_for_at( hi, Kbb )
          ENDIF
-         CALL iom_get( numrtr, jpdom_auto, 'Silicalim', xksi(:,:), ldxios = lrxios )
+         CALL iom_get( numrtr, jpdom_auto, 'Silicalim', xksi(:,:) )
          IF( iom_varid( numrtr, 'Silicamax', ldstop = .FALSE. ) > 0 ) THEN
-            CALL iom_get( numrtr, jpdom_auto, 'Silicamax' , xksimax(:,:), ldxios = lrxios  )
+            CALL iom_get( numrtr, jpdom_auto, 'Silicamax' , xksimax(:,:)  )
          ELSE
             xksimax(:,:) = xksi(:,:)
@@ -347,5 +346,5 @@
          !
          IF( iom_varid( numrtr, 'tcflxcum', ldstop = .FALSE. ) > 0 ) THEN  ! cumulative total flux of carbon
-            CALL iom_get( numrtr, 'tcflxcum' , t_oce_co2_flx_cum, ldxios = lrxios  )
+            CALL iom_get( numrtr, 'tcflxcum' , t_oce_co2_flx_cum  )
          ELSE
             t_oce_co2_flx_cum = 0._wp
@@ -354,7 +353,7 @@
          IF( ln_p5z ) THEN
             IF( iom_varid( numrtr, 'sized', ldstop = .FALSE. ) > 0 ) THEN
-               CALL iom_get( numrtr, jpdom_auto, 'sizep' , sizep(:,:,:), ldxios = lrxios  )
-               CALL iom_get( numrtr, jpdom_auto, 'sizen' , sizen(:,:,:), ldxios = lrxios  )
-               CALL iom_get( numrtr, jpdom_auto, 'sized' , sized(:,:,:), ldxios = lrxios  )
+               CALL iom_get( numrtr, jpdom_auto, 'sizep' , sizep(:,:,:)  )
+               CALL iom_get( numrtr, jpdom_auto, 'sizen' , sizen(:,:,:)  )
+               CALL iom_get( numrtr, jpdom_auto, 'sized' , sized(:,:,:)  )
             ELSE
                sizep(:,:,:) = 1.
@@ -363,5 +362,4 @@
             ENDIF
         ENDIF
-        IF(lrxios) CALL iom_swap(cxios_context)
         !
       ELSEIF( TRIM(cdrw) == 'WRITE' ) THEN
@@ -371,15 +369,13 @@
             IF(lwp) WRITE(numout,*) '~~~~~~~'
          ENDIF
-         IF( lwxios ) CALL iom_swap(      cw_toprst_cxt         )
-         CALL iom_rstput( kt, nitrst, numrtw, 'PH', hi(:,:,:),               ldxios = lwxios )
-         CALL iom_rstput( kt, nitrst, numrtw, 'Silicalim', xksi(:,:),        ldxios = lwxios )
-         CALL iom_rstput( kt, nitrst, numrtw, 'Silicamax', xksimax(:,:),     ldxios = lwxios )
-         CALL iom_rstput( kt, nitrst, numrtw, 'tcflxcum', t_oce_co2_flx_cum, ldxios = lwxios )
+         CALL iom_rstput( kt, nitrst, numrtw, 'PH', hi(:,:,:)           )
+         CALL iom_rstput( kt, nitrst, numrtw, 'Silicalim', xksi(:,:)    )
+         CALL iom_rstput( kt, nitrst, numrtw, 'Silicamax', xksimax(:,:) )
+         CALL iom_rstput( kt, nitrst, numrtw, 'tcflxcum', t_oce_co2_flx_cum )
          IF( ln_p5z ) THEN
-            CALL iom_rstput( kt, nitrst, numrtw, 'sizep', sizep(:,:,:), ldxios = lwxios )
-            CALL iom_rstput( kt, nitrst, numrtw, 'sizen', sizen(:,:,:), ldxios = lwxios )
-            CALL iom_rstput( kt, nitrst, numrtw, 'sized', sized(:,:,:), ldxios = lwxios )
-         ENDIF
-         IF( lwxios ) CALL iom_swap(      cxios_context         )
+            CALL iom_rstput( kt, nitrst, numrtw, 'sizep', sizep(:,:,:) )
+            CALL iom_rstput( kt, nitrst, numrtw, 'sizen', sizen(:,:,:) )
+            CALL iom_rstput( kt, nitrst, numrtw, 'sized', sized(:,:,:) )
+         ENDIF
       ENDIF
       !
Index: NEMO/branches/2020/dev_12905_xios_restart/src/TOP/PISCES/SED/sed.F90
===================================================================
--- NEMO/branches/2020/dev_12905_xios_restart/src/TOP/PISCES/SED/sed.F90	(revision 13931)
+++ NEMO/branches/2020/dev_12905_xios_restart/src/TOP/PISCES/SED/sed.F90	(revision 13932)
@@ -44,5 +44,4 @@
    REAL    , PUBLIC               ::  sedmask
    REAL(wp), PUBLIC               ::  denssol                !: density of solid material
-   INTEGER , PUBLIC               ::  numrsr, numrsw   !: logical unit for sed restart (read and write)
    LOGICAL , PUBLIC               ::  lrst_sed       !: logical to control the trc restart write
    LOGICAL , PUBLIC               ::  ln_rst_sed  = .TRUE.     !: initialisation from a restart file or not
Index: NEMO/branches/2020/dev_12905_xios_restart/src/TOP/PISCES/SED/sedrst.F90
===================================================================
--- NEMO/branches/2020/dev_12905_xios_restart/src/TOP/PISCES/SED/sedrst.F90	(revision 13931)
+++ NEMO/branches/2020/dev_12905_xios_restart/src/TOP/PISCES/SED/sedrst.F90	(revision 13932)
@@ -91,6 +91,6 @@
                clpname = TRIM(Agrif_CFixed())//"_"//clname
             ENDIF
-            CALL iom_init( cw_sedrst_cxt, fname = TRIM(clpath)//TRIM(clpname), ld_closedef = .FALSE. )
-            CALL iom_swap(      cxios_context          )
+            numrsw = iom_xios_setid(TRIM(clpath)//TRIM(clpname))
+            CALL iom_init( cw_sedrst_cxt, kdid = numrsw, ld_closedef = .FALSE. )
 #else
                clinfo = 'Can not use XIOS in trc_rst_opn'
@@ -138,9 +138,8 @@
       zdta2 = 0.
 
-      IF(lrxios) CALL iom_swap(cr_sedrst_cxt)
       DO jn = 1, jptrased
          cltra = TRIM(sedtrcd(jn))
          IF( iom_varid( numrsr, TRIM(cltra) , ldstop = .FALSE. ) > 0 ) THEN
-            CALL iom_get( numrsr, jpdom_auto, TRIM(cltra), zdta(:,:,:,jn), ldxios = lrxios )
+            CALL iom_get( numrsr, jpdom_auto, TRIM(cltra), zdta(:,:,:,jn) )
          ELSE
             zdta(:,:,:,jn) = 0.0
@@ -161,5 +160,5 @@
          cltra = TRIM(seddia3d(jn))
          IF( iom_varid( numrsr, TRIM(cltra) , ldstop = .FALSE. ) > 0 ) THEN
-            CALL iom_get( numrsr, jpdom_auto, TRIM(cltra), zdta1(:,:,:,jn), ldxios = lrxios )
+            CALL iom_get( numrsr, jpdom_auto, TRIM(cltra), zdta1(:,:,:,jn) )
          ELSE
             zdta1(:,:,:,jn) = 0.0
@@ -188,5 +187,5 @@
       cltra = "dbioturb"
       IF( iom_varid( numrsr, TRIM(cltra) , ldstop = .FALSE. ) > 0 ) THEN
-         CALL iom_get( numrsr, jpdom_auto, TRIM(cltra), zdta2(:,:,:), ldxios = lrxios )
+         CALL iom_get( numrsr, jpdom_auto, TRIM(cltra), zdta2(:,:,:) )
       ELSE
          zdta2(:,:,:) = 0.0
@@ -198,5 +197,5 @@
       cltra = "irrig"
       IF( iom_varid( numrsr, TRIM(cltra) , ldstop = .FALSE. ) > 0 ) THEN
-         CALL iom_get( numrsr, jpdom_auto, TRIM(cltra), zdta2(:,:,:), ldxios = lrxios )
+         CALL iom_get( numrsr, jpdom_auto, TRIM(cltra), zdta2(:,:,:) )
       ELSE
          zdta2(:,:,:) = 0.0
@@ -208,5 +207,5 @@
       cltra = "sedligand"
       IF( iom_varid( numrsr, TRIM(cltra) , ldstop = .FALSE. ) > 0 ) THEN
-         CALL iom_get( numrsr, jpdom_auto, TRIM(cltra), zdta2(:,:,:), ldxios = lrxios )
+         CALL iom_get( numrsr, jpdom_auto, TRIM(cltra), zdta2(:,:,:) )
       ELSE
          zdta2(:,:,:) = 0.0
@@ -215,5 +214,4 @@
       CALL pack_arr( jpoce, sedligand(1:jpoce,1:jpksed), &
          &             zdta2(1:jpi,1:jpj,1:jpksed), iarroce(1:jpoce) )
-      IF(lrxios) CALL iom_swap(cxios_context)
       IF( ln_timing )  CALL timing_stop('sed_rst_read')
      
@@ -259,7 +257,6 @@
       !! 1. WRITE in nutwrs
       !! ------------------
-      IF( lwxios ) CALL iom_swap(      cw_sedrst_cxt         )
 !     zinfo(1) = REAL( kt)
-      CALL iom_rstput( kt, nitrst, numrsw, 'kt', REAL( kt    , wp), ldxios = lwxios )
+      CALL iom_rstput( kt, nitrst, numrsw, 'kt', REAL( kt    , wp) )
 
       ! Back to 2D geometry
@@ -291,10 +288,10 @@
       DO jn = 1, jptrased
          cltra = TRIM(sedtrcd(jn))
-         CALL iom_rstput( kt, nitrst, numrsw, TRIM(cltra), trcsedi(:,:,:,jn), ldxios = lwxios )
+         CALL iom_rstput( kt, nitrst, numrsw, TRIM(cltra), trcsedi(:,:,:,jn) )
       ENDDO
 
       DO jn = 1, 2
          cltra = TRIM(seddia3d(jn))
-         CALL iom_rstput( kt, nitrst, numrsw, TRIM(cltra), flxsedi3d(:,:,:,jn), ldxios = lwxios )
+         CALL iom_rstput( kt, nitrst, numrsw, TRIM(cltra), flxsedi3d(:,:,:,jn) )
       ENDDO
 
@@ -303,5 +300,5 @@
 
       cltra = "dbioturb"
-      CALL iom_rstput( kt, nitrst, numrsw, TRIM(cltra), zdta2(:,:,:), ldxios = lwxios )
+      CALL iom_rstput( kt, nitrst, numrsw, TRIM(cltra), zdta2(:,:,:) )
 
       CALL unpack_arr( jpoce, zdta2(1:jpi,1:jpj,1:jpksed)  , iarroce(1:jpoce), &
@@ -309,5 +306,5 @@
 
       cltra = "irrig"
-      CALL iom_rstput( kt, nitrst, numrsw, TRIM(cltra), zdta2(:,:,:), ldxios = lwxios )
+      CALL iom_rstput( kt, nitrst, numrsw, TRIM(cltra), zdta2(:,:,:) )
 
       CALL unpack_arr( jpoce, zdta2(1:jpi,1:jpj,1:jpksed)  , iarroce(1:jpoce), &
@@ -315,6 +312,5 @@
 
       cltra = "sedligand"
-      CALL iom_rstput( kt, nitrst, numrsw, TRIM(cltra), zdta2(:,:,:), ldxios = lwxios )
-      IF( lwxios ) CALL iom_swap(      cxios_context         )
+      CALL iom_rstput( kt, nitrst, numrsw, TRIM(cltra), zdta2(:,:,:) )
 
       IF( kt == nitrst ) THEN
@@ -323,4 +319,6 @@
           ELSE
              CALL iom_context_finalize( cw_sedrst_cxt ) 
+             iom_file(numrsw)%nfid       = 0
+             numrsw = 0
           ENDIF
           IF( l_offline .AND. ln_rst_list ) THEN
@@ -384,15 +382,12 @@
                 cr_sedrst_cxt = 'sed_rst'
                 IF(lwp) WRITE(numout,*) 'Enable restart reading by XIOS for SED'
-                IF( TRIM(Agrif_CFixed()) == '0' ) THEN
-                   clpname = cn_sedrst_in
-                ELSE
-                   clpname = TRIM(Agrif_CFixed())//"_"//cn_sedrst_in   
-                ENDIF
-                CALL iom_init( cr_sedrst_cxt, fname = TRIM(cn_sedrst_indir)//'/'//TRIM(clpname), &
-                                                idfp = iom_file(numrsr)%nfid, ld_closedef = .TRUE. )
-            ENDIF
-            IF(lrxios) CALL iom_swap(cr_sedrst_cxt)
-            CALL iom_get ( numrsr, 'kt', zkt, ldxios = lrxios )   ! last time-step of previous run
-            IF(lrxios) CALL iom_swap(cxios_context)
+!               IF( TRIM(Agrif_CFixed()) == '0' ) THEN
+!                  clpname = cn_sedrst_in
+!               ELSE
+!                  clpname = TRIM(Agrif_CFixed())//"_"//cn_sedrst_in   
+!               ENDIF
+                CALL iom_init( cr_sedrst_cxt, kdid = numrsr, ld_closedef = .TRUE. )
+            ENDIF
+            CALL iom_get ( numrsr, 'kt', zkt )   ! last time-step of previous run
             IF(lwp) THEN
                WRITE(numsed,*) ' *** Info read in restart : '
@@ -415,9 +410,7 @@
             !                                          ! set the date in offline mode
             IF( ln_rst_sed .AND. nn_rstsed == 2 ) THEN
-               IF(lrxios) CALL iom_swap(cr_sedrst_cxt)
-               CALL iom_get( numrsr, 'ndastp', zndastp, ldxios = lrxios )
+               CALL iom_get( numrsr, 'ndastp', zndastp )
                ndastp = NINT( zndastp )
-               CALL iom_get( numrsr, 'adatrj', adatrj, ldxios = lrxios  )
-               IF(lrxios) CALL iom_swap(cr_ocerst_cxt)
+               CALL iom_get( numrsr, 'adatrj', adatrj  )
              ELSE
                ndastp = ndate0 - 1     ! ndate0 read in the namelist in dom_nam
@@ -445,10 +438,8 @@
             IF( lwxios ) CALL iom_init_closedef(cw_sedrst_cxt)
          ENDIF
-         IF( lwxios ) CALL iom_swap(      cw_sedrst_cxt         )
-         CALL iom_rstput( kt, nitrst, numrsw, 'kt'     , REAL( kt    , wp), ldxios = lwxios )   ! time-step
-         CALL iom_rstput( kt, nitrst, numrsw, 'ndastp' , REAL( ndastp, wp), ldxios = lwxios )   ! date
-         CALL iom_rstput( kt, nitrst, numrsw, 'adatrj' , adatrj,            ldxios = lwxios )   ! number of elapsed days since
+         CALL iom_rstput( kt, nitrst, numrsw, 'kt'     , REAL( kt    , wp) )   ! time-step
+         CALL iom_rstput( kt, nitrst, numrsw, 'ndastp' , REAL( ndastp, wp) )   ! date
+         CALL iom_rstput( kt, nitrst, numrsw, 'adatrj' , adatrj )   ! number of elapsed days since
          !                                                                                      ! the begining of the run [s]
-         IF( lwxios ) CALL iom_swap(      cxios_context         )
       ENDIF
 
Index: NEMO/branches/2020/dev_12905_xios_restart/src/TOP/PISCES/SED/sedstp.F90
===================================================================
--- NEMO/branches/2020/dev_12905_xios_restart/src/TOP/PISCES/SED/sedstp.F90	(revision 13931)
+++ NEMO/branches/2020/dev_12905_xios_restart/src/TOP/PISCES/SED/sedstp.F90	(revision 13932)
@@ -87,5 +87,5 @@
           CALL iom_close( numrsr )       ! close input tracer restart file
           IF(lrxios) CALL iom_context_finalize(      cr_sedrst_cxt  )
-!          IF(lwm) CALL FLUSH( numont )   ! flush namelist output
+!         IF(lwm) CALL FLUSH( numont )   ! flush namelist output
       ENDIF
       IF( lrst_sed )            CALL sed_rst_wri( kt )   ! restart file output
Index: NEMO/branches/2020/dev_12905_xios_restart/src/TOP/TRP/trcsbc.F90
===================================================================
--- NEMO/branches/2020/dev_12905_xios_restart/src/TOP/TRP/trcsbc.F90	(revision 13931)
+++ NEMO/branches/2020/dev_12905_xios_restart/src/TOP/TRP/trcsbc.F90	(revision 13932)
@@ -87,9 +87,7 @@
             IF(lwp) WRITE(numout,*) '          nittrc000-1 surface tracer content forcing fields read in the restart file'
             zfact = 0.5_wp
-            IF(lrxios) CALL iom_swap(cr_toprst_cxt)
             DO jn = 1, jptra
-               CALL iom_get( numrtr, jpdom_auto, 'sbc_'//TRIM(ctrcnm(jn))//'_b', sbc_trc_b(:,:,jn), ldxios = lrxios )   ! before tracer content sbc
+               CALL iom_get( numrtr, jpdom_auto, 'sbc_'//TRIM(ctrcnm(jn))//'_b', sbc_trc_b(:,:,jn) )   ! before tracer content sbc
             END DO
-            IF(lrxios) CALL iom_swap(cxios_context)
          ELSE                                         ! No restart or restart not found: Euler forward time stepping
            zfact = 1._wp
@@ -183,9 +181,7 @@
             &                    'at it= ', kt,' date= ', ndastp
          IF(lwp) WRITE(numout,*) '~~~~'
-         IF( lwxios ) CALL iom_swap(      cw_toprst_cxt         )
-         DO jn = 1, jptra
-            CALL iom_rstput( kt, nitrst, numrtw, 'sbc_'//TRIM(ctrcnm(jn))//'_b', sbc_trc(:,:,jn), ldxios = lwxios )
-         END DO
-         IF( lwxios ) CALL iom_swap(      cxios_context         )
+         DO jn = 1, jptra
+            CALL iom_rstput( kt, nitrst, numrtw, 'sbc_'//TRIM(ctrcnm(jn))//'_b', sbc_trc(:,:,jn) )
+         END DO
       ENDIF
       !
Index: NEMO/branches/2020/dev_12905_xios_restart/src/TOP/trc.F90
===================================================================
--- NEMO/branches/2020/dev_12905_xios_restart/src/TOP/trc.F90	(revision 13931)
+++ NEMO/branches/2020/dev_12905_xios_restart/src/TOP/trc.F90	(revision 13932)
@@ -21,6 +21,4 @@
    INTEGER, PUBLIC ::   numonr     = -1   !: reference passive tracer namelist output output.namelist.top
    INTEGER, PUBLIC ::   numstr            !: tracer statistics
-   INTEGER, PUBLIC ::   numrtr     = -1   !: trc restart (read )
-   INTEGER, PUBLIC ::   numrtw            !: trc restart ( write )
    CHARACTER(:), ALLOCATABLE, PUBLIC ::   numnat_ref   !: character buffer for reference passive tracer namelist_top_ref
    CHARACTER(:), ALLOCATABLE, PUBLIC ::   numnat_cfg   !: character buffer for configuration specific passive tracer namelist_top_cfg
Index: NEMO/branches/2020/dev_12905_xios_restart/src/TOP/trcrst.F90
===================================================================
--- NEMO/branches/2020/dev_12905_xios_restart/src/TOP/trcrst.F90	(revision 13931)
+++ NEMO/branches/2020/dev_12905_xios_restart/src/TOP/trcrst.F90	(revision 13932)
@@ -102,6 +102,6 @@
                clpname = TRIM(Agrif_CFixed())//"_"//clname
             ENDIF
-            CALL iom_init( cw_toprst_cxt, fname = TRIM(clpath)//TRIM(clpname), ld_closedef = .FALSE. )
-            CALL iom_swap(      cxios_context          )
+            numrtw = iom_xios_setid(TRIM(clpath)//TRIM(clpname))
+            CALL iom_init( cw_toprst_cxt, kdid = numrtw, ld_closedef = .FALSE. )
 #else
                clinfo = 'Can not use XIOS in trc_rst_opn'
@@ -130,15 +130,13 @@
 
       ! READ prognostic variables and computes diagnostic variable
-      IF(lrxios) CALL iom_swap(cr_toprst_cxt)
       DO jn = 1, jptra
-         CALL iom_get( numrtr, jpdom_auto, 'TRN'//ctrcnm(jn), tr(:,:,:,jn,Kmm), ldxios = lrxios )
+         CALL iom_get( numrtr, jpdom_auto, 'TRN'//ctrcnm(jn), tr(:,:,:,jn,Kmm) )
       END DO
 
       DO jn = 1, jptra
-         CALL iom_get( numrtr, jpdom_auto, 'TRB'//ctrcnm(jn), tr(:,:,:,jn,Kbb), ldxios = lrxios )
-      END DO
-      !
-      CALL iom_delay_rst( 'READ', 'TOP', numrtr )   ! read only TOP delayed global communication variables
-      IF(lrxios) CALL iom_swap(cxios_context) 
+         CALL iom_get( numrtr, jpdom_auto, 'TRB'//ctrcnm(jn), tr(:,:,:,jn,Kbb) )
+      END DO
+      !
+      IF(.NOT.lrxios) CALL iom_delay_rst( 'READ', 'TOP', numrtr )   ! read only TOP delayed global communication variables
    END SUBROUTINE trc_rst_read
 
@@ -155,18 +153,16 @@
       !!----------------------------------------------------------------------
       !
-      IF( lwxios ) CALL iom_swap(      cw_toprst_cxt         )
-      CALL iom_rstput( kt, nitrst, numrtw, 'rdttrc1', rn_Dt, ldxios = lwxios )   ! passive tracer time step (= ocean time step)
+      CALL iom_rstput( kt, nitrst, numrtw, 'rdttrc1', rn_Dt )   ! passive tracer time step (= ocean time step)
       ! prognostic variables 
       ! -------------------- 
       DO jn = 1, jptra
-         CALL iom_rstput( kt, nitrst, numrtw, 'TRN'//ctrcnm(jn), tr(:,:,:,jn,Kmm), ldxios = lwxios )
+         CALL iom_rstput( kt, nitrst, numrtw, 'TRN'//ctrcnm(jn), tr(:,:,:,jn,Kmm) )
       END DO
 
       DO jn = 1, jptra
-         CALL iom_rstput( kt, nitrst, numrtw, 'TRB'//ctrcnm(jn), tr(:,:,:,jn,Kbb), ldxios = lwxios )
-      END DO
-      IF( lwxios ) CALL iom_swap(      cxios_context         )
-      !
-      CALL iom_delay_rst( 'WRITE', 'TOP', numrtw )   ! save only TOP delayed global communication variables
+         CALL iom_rstput( kt, nitrst, numrtw, 'TRB'//ctrcnm(jn), tr(:,:,:,jn,Kbb) )
+      END DO
+
+      IF( .NOT. lwxios ) CALL iom_delay_rst( 'WRITE', 'TOP', numrtw )   ! save only TOP delayed global communication variables
     
       IF( kt == nitrst ) THEN
@@ -174,4 +170,6 @@
           IF(lwxios) THEN
              CALL iom_context_finalize(      cw_toprst_cxt          )
+             iom_file(numrtw)%nfid       = 0
+             numrtw = 0
           ELSE
              CALL iom_close( numrtw )     ! close the restart file (only at last time step)
@@ -237,16 +235,13 @@
                 cr_toprst_cxt = 'top_rst'
                 IF(lwp) WRITE(numout,*) 'Enable restart reading by XIOS for TOP'
-                IF( TRIM(Agrif_CFixed()) == '0' ) THEN
-                   clpname = cn_trcrst_in
-                ELSE
-                   clpname = TRIM(Agrif_CFixed())//"_"//cn_trcrst_in   
-                ENDIF
-                CALL iom_init( cr_toprst_cxt, fname = TRIM(cn_trcrst_indir)//'/'//TRIM(clpname), &
-                                          idfp = iom_file(numrtr)%nfid, ld_closedef = .TRUE. )
-            ENDIF
-
-            IF(lrxios) CALL iom_swap(cr_toprst_cxt)
-            CALL iom_get ( numrtr, 'kt', zkt, ldxios = lrxios )   ! last time-step of previous run
-            IF(lrxios) CALL iom_swap(cxios_context)
+!               IF( TRIM(Agrif_CFixed()) == '0' ) THEN
+!                  clpname = cn_trcrst_in
+!               ELSE
+!                  clpname = TRIM(Agrif_CFixed())//"_"//cn_trcrst_in   
+!               ENDIF
+                CALL iom_init( cr_toprst_cxt, kdid = numrtr, ld_closedef = .TRUE. )
+            ENDIF
+
+            CALL iom_get ( numrtr, 'kt', zkt )   ! last time-step of previous run
 
             IF(lwp) THEN
@@ -270,10 +265,8 @@
             !                                          ! set the date in offline mode
             IF( ln_rsttr .AND. nn_rsttr == 2 ) THEN
-               IF(lrxios) CALL iom_swap(cr_toprst_cxt)
-               CALL iom_get( numrtr, 'ndastp', zndastp, ldxios = lrxios )
+               CALL iom_get( numrtr, 'ndastp', zndastp )
                ndastp = NINT( zndastp )
-               CALL iom_get( numrtr, 'adatrj', adatrj, ldxios = lrxios  )
-               CALL iom_get( numrtr, 'ntime' , ktime, ldxios = lrxios   )
-               IF(lrxios) CALL iom_swap(cxios_context)
+               CALL iom_get( numrtr, 'adatrj', adatrj  )
+               CALL iom_get( numrtr, 'ntime' , ktime   )
                nn_time0=INT(ktime)
                ! calculate start time in hours and minutes
@@ -335,11 +328,9 @@
             IF(lwp) WRITE(numout,*) '~~~~~~~'
          ENDIF
-         IF( lwxios ) CALL iom_swap(      cw_toprst_cxt         )
-         CALL iom_rstput( kt, nitrst, numrtw, 'kt'     , REAL( kt    , wp)  , ldxios = lwxios )   ! time-step
-         CALL iom_rstput( kt, nitrst, numrtw, 'ndastp' , REAL( ndastp, wp)  , ldxios = lwxios )   ! date
-         CALL iom_rstput( kt, nitrst, numrtw, 'adatrj' , adatrj             , ldxios = lwxios )   ! number of elapsed days since
+         CALL iom_rstput( kt, nitrst, numrtw, 'kt'     , REAL( kt    , wp)   )   ! time-step
+         CALL iom_rstput( kt, nitrst, numrtw, 'ndastp' , REAL( ndastp, wp)   )   ! date
+         CALL iom_rstput( kt, nitrst, numrtw, 'adatrj' , adatrj              )   ! number of elapsed days since
          !                                                                     ! the begining of the run [s]
-         CALL iom_rstput( kt, nitrst, numrtw, 'ntime'  , REAL( nn_time0, wp), ldxios = lwxios ) ! time
-         IF( lwxios ) CALL iom_swap(      cxios_context         )
+         CALL iom_rstput( kt, nitrst, numrtw, 'ntime'  , REAL( nn_time0, wp) ) ! time
       ENDIF
 
Index: NEMO/branches/2020/dev_12905_xios_restart/src/TOP/trcstp.F90
===================================================================
--- NEMO/branches/2020/dev_12905_xios_restart/src/TOP/trcstp.F90	(revision 13931)
+++ NEMO/branches/2020/dev_12905_xios_restart/src/TOP/trcstp.F90	(revision 13932)
@@ -197,18 +197,17 @@
            &                              .AND. iom_varid( numrtr, 'ktdcy'    , ldstop = .FALSE. ) > 0  &
            &                              .AND. iom_varid( numrtr, 'nrdcy'    , ldstop = .FALSE. ) > 0  ) THEN
-            IF(lrxios) CALL iom_swap(cr_toprst_cxt)
-            CALL iom_get( numrtr, 'ktdcy', zkt, ldxios = lrxios )  
+            CALL iom_get( numrtr, 'ktdcy', zkt )  
             rsecfst = INT( zkt ) * rn_Dt
             IF(lwp) WRITE(numout,*) 'trc_qsr_mean:   qsr_mean read in the restart file at time-step rsecfst =', rsecfst, ' s '
-            CALL iom_get( numrtr, jpdom_auto, 'qsr_mean', qsr_mean, ldxios = lrxios )   !  A mean of qsr
-            CALL iom_get( numrtr, 'nrdcy', zrec, ldxios = lrxios )   !  Number of record per days
+            CALL iom_get( numrtr, jpdom_auto, 'qsr_mean', qsr_mean )   !  A mean of qsr
+            CALL iom_get( numrtr, 'nrdcy', zrec )   !  Number of record per days
             IF( INT( zrec ) == nb_rec_per_day ) THEN
                DO jn = 1, nb_rec_per_day 
                   IF( jn <= 9 )  THEN
                     WRITE(cl1,'(i1)') jn
-                    CALL iom_get( numrtr, jpdom_auto, 'qsr_arr_'//cl1, qsr_arr(:,:,jn), ldxios = lrxios )   !  A mean of qsr
+                    CALL iom_get( numrtr, jpdom_auto, 'qsr_arr_'//cl1, qsr_arr(:,:,jn) )   !  A mean of qsr
                   ELSE
                     WRITE(cl2,'(i2.2)') jn
-                    CALL iom_get( numrtr, jpdom_auto, 'qsr_arr_'//cl2, qsr_arr(:,:,jn), ldxios = lrxios )   !  A mean of qsr
+                    CALL iom_get( numrtr, jpdom_auto, 'qsr_arr_'//cl2, qsr_arr(:,:,jn) )   !  A mean of qsr
                   ENDIF
               END DO
@@ -218,5 +217,4 @@
                ENDDO
             ENDIF
-            IF(lrxios) CALL iom_swap(cxios_context)
          ELSE                                         !* no restart: set from nit000 values
             IF(lwp) WRITE(numout,*) 'trc_qsr_mean:   qsr_mean set to nit000 values'
@@ -252,18 +250,16 @@
          zkt  = REAL( ktdcy, wp )
          zrec = REAL( nb_rec_per_day, wp )
-         IF( lwxios ) CALL iom_swap(      cw_toprst_cxt         )
-         CALL iom_rstput( kt, nitrst, numrtw, 'ktdcy', zkt, ldxios = lwxios  )
-         CALL iom_rstput( kt, nitrst, numrtw, 'nrdcy', zrec, ldxios = lwxios )
+         CALL iom_rstput( kt, nitrst, numrtw, 'ktdcy', zkt  )
+         CALL iom_rstput( kt, nitrst, numrtw, 'nrdcy', zrec )
           DO jn = 1, nb_rec_per_day 
              IF( jn <= 9 )  THEN
                WRITE(cl1,'(i1)') jn
-               CALL iom_rstput( kt, nitrst, numrtw, 'qsr_arr_'//cl1, qsr_arr(:,:,jn), ldxios = lwxios )
+               CALL iom_rstput( kt, nitrst, numrtw, 'qsr_arr_'//cl1, qsr_arr(:,:,jn) )
              ELSE
                WRITE(cl2,'(i2.2)') jn
-               CALL iom_rstput( kt, nitrst, numrtw, 'qsr_arr_'//cl2, qsr_arr(:,:,jn), ldxios = lwxios )
+               CALL iom_rstput( kt, nitrst, numrtw, 'qsr_arr_'//cl2, qsr_arr(:,:,jn) )
              ENDIF
          END DO
-         CALL iom_rstput( kt, nitrst, numrtw, 'qsr_mean', qsr_mean(:,:), ldxios = lwxios )
-         IF( lwxios ) CALL iom_swap(      cxios_context         )
+         CALL iom_rstput( kt, nitrst, numrtw, 'qsr_mean', qsr_mean(:,:) )
       ENDIF
       !
Index: NEMO/branches/2020/dev_12905_xios_restart/tests/CANAL/MY_SRC/domvvl.F90
===================================================================
--- NEMO/branches/2020/dev_12905_xios_restart/tests/CANAL/MY_SRC/domvvl.F90	(revision 13931)
+++ NEMO/branches/2020/dev_12905_xios_restart/tests/CANAL/MY_SRC/domvvl.F90	(revision 13932)
@@ -785,6 +785,5 @@
          IF( ln_rstart ) THEN                   !* Read the restart file
             CALL rst_read_open                  !  open the restart file if necessary
-            IF( lrxios ) CALL iom_swap( cr_ocerst_cxt )
-            CALL iom_get( numror, jpdom_auto, 'sshn'   , ssh(:,:,Kmm), ldxios = lrxios    )
+            CALL iom_get( numror, jpdom_auto, 'sshn'   , ssh(:,:,Kmm)    )
             !
             id1 = iom_varid( numror, 'e3t_b', ldstop = .FALSE. )
@@ -799,6 +798,6 @@
             !
             IF( MIN( id1, id2 ) > 0 ) THEN       ! all required arrays exist
-               CALL iom_get( numror, jpdom_auto, 'e3t_b', e3t(:,:,:,Kbb), ldxios = lrxios )
-               CALL iom_get( numror, jpdom_auto, 'e3t_n', e3t(:,:,:,Kmm), ldxios = lrxios )
+               CALL iom_get( numror, jpdom_auto, 'e3t_b', e3t(:,:,:,Kbb) )
+               CALL iom_get( numror, jpdom_auto, 'e3t_n', e3t(:,:,:,Kmm) )
                ! needed to restart if land processor not computed 
                IF(lwp) write(numout,*) 'dom_vvl_rst : e3t(:,:,:,Kbb) and e3t(:,:,:,Kmm) found in restart files'
@@ -814,5 +813,5 @@
                IF(lwp) write(numout,*) 'e3t_n set equal to e3t_b.'
                IF(lwp) write(numout,*) 'l_1st_euler is forced to true'
-               CALL iom_get( numror, jpdom_auto, 'e3t_b', e3t(:,:,:,Kbb), ldxios = lrxios )
+               CALL iom_get( numror, jpdom_auto, 'e3t_b', e3t(:,:,:,Kbb) )
                e3t(:,:,:,Kmm) = e3t(:,:,:,Kbb)
                l_1st_euler = .true.
@@ -821,5 +820,5 @@
                IF(lwp) write(numout,*) 'e3t_b set equal to e3t_n.'
                IF(lwp) write(numout,*) 'l_1st_euler is forced to true'
-               CALL iom_get( numror, jpdom_auto, 'e3t_n', e3t(:,:,:,Kmm), ldxios = lrxios )
+               CALL iom_get( numror, jpdom_auto, 'e3t_n', e3t(:,:,:,Kmm) )
                e3t(:,:,:,Kbb) = e3t(:,:,:,Kmm)
                l_1st_euler = .true.
@@ -846,6 +845,6 @@
                !                          ! ----------------------- !
                IF( MIN( id3, id4 ) > 0 ) THEN  ! all required arrays exist
-                  CALL iom_get( numror, jpdom_auto, 'tilde_e3t_b', tilde_e3t_b(:,:,:), ldxios = lrxios )
-                  CALL iom_get( numror, jpdom_auto, 'tilde_e3t_n', tilde_e3t_n(:,:,:), ldxios = lrxios )
+                  CALL iom_get( numror, jpdom_auto, 'tilde_e3t_b', tilde_e3t_b(:,:,:) )
+                  CALL iom_get( numror, jpdom_auto, 'tilde_e3t_n', tilde_e3t_n(:,:,:) )
                ELSE                            ! one at least array is missing
                   tilde_e3t_b(:,:,:) = 0.0_wp
@@ -856,5 +855,5 @@
                   !                       ! ------------ !
                   IF( id5 > 0 ) THEN  ! required array exists
-                     CALL iom_get( numror, jpdom_auto, 'hdiv_lf', hdiv_lf(:,:,:), ldxios = lrxios )
+                     CALL iom_get( numror, jpdom_auto, 'hdiv_lf', hdiv_lf(:,:,:) )
                   ELSE                ! array is missing
                      hdiv_lf(:,:,:) = 0.0_wp
@@ -862,5 +861,4 @@
                ENDIF
             ENDIF
-            IF( lrxios ) CALL iom_swap( cxios_context )
             !
          ELSE                                   !* Initialize at "rest"
@@ -931,23 +929,21 @@
          !                                   ! ===================
          IF(lwp) WRITE(numout,*) '---- dom_vvl_rst ----'
-         IF( lwxios ) CALL iom_swap(      cw_ocerst_cxt          )
          !                                           ! --------- !
          !                                           ! all cases !
          !                                           ! --------- !
-         CALL iom_rstput( kt, nitrst, numrow, 'e3t_b', e3t(:,:,:,Kbb), ldxios = lwxios )
-         CALL iom_rstput( kt, nitrst, numrow, 'e3t_n', e3t(:,:,:,Kmm), ldxios = lwxios )
+         CALL iom_rstput( kt, nitrst, numrow, 'e3t_b', e3t(:,:,:,Kbb) )
+         CALL iom_rstput( kt, nitrst, numrow, 'e3t_n', e3t(:,:,:,Kmm) )
          !                                           ! ----------------------- !
          IF( ln_vvl_ztilde .OR. ln_vvl_layer ) THEN  ! z_tilde and layer cases !
             !                                        ! ----------------------- !
-            CALL iom_rstput( kt, nitrst, numrow, 'tilde_e3t_b', tilde_e3t_b(:,:,:), ldxios = lwxios)
-            CALL iom_rstput( kt, nitrst, numrow, 'tilde_e3t_n', tilde_e3t_n(:,:,:), ldxios = lwxios)
+            CALL iom_rstput( kt, nitrst, numrow, 'tilde_e3t_b', tilde_e3t_b(:,:,:))
+            CALL iom_rstput( kt, nitrst, numrow, 'tilde_e3t_n', tilde_e3t_n(:,:,:))
          END IF
          !                                           ! -------------!    
          IF( ln_vvl_ztilde ) THEN                    ! z_tilde case !
             !                                        ! ------------ !
-            CALL iom_rstput( kt, nitrst, numrow, 'hdiv_lf', hdiv_lf(:,:,:), ldxios = lwxios)
+            CALL iom_rstput( kt, nitrst, numrow, 'hdiv_lf', hdiv_lf(:,:,:))
          ENDIF
          !
-         IF( lwxios ) CALL iom_swap(      cxios_context          )
       ENDIF
       !
Index: NEMO/branches/2020/dev_12905_xios_restart/tests/VORTEX/MY_SRC/domvvl.F90
===================================================================
--- NEMO/branches/2020/dev_12905_xios_restart/tests/VORTEX/MY_SRC/domvvl.F90	(revision 13931)
+++ NEMO/branches/2020/dev_12905_xios_restart/tests/VORTEX/MY_SRC/domvvl.F90	(revision 13932)
@@ -785,6 +785,5 @@
          IF( ln_rstart ) THEN                   !* Read the restart file
             CALL rst_read_open                  !  open the restart file if necessary
-            IF( lrxios ) CALL iom_swap( cr_ocerst_cxt )
-            CALL iom_get( numror, jpdom_auto, 'sshn'   , ssh(:,:,Kmm), ldxios = lrxios    )
+            CALL iom_get( numror, jpdom_auto, 'sshn'   , ssh(:,:,Kmm)    )
             !
             id1 = iom_varid( numror, 'e3t_b', ldstop = .FALSE. )
@@ -799,6 +798,6 @@
             !
             IF( MIN( id1, id2 ) > 0 ) THEN       ! all required arrays exist
-               CALL iom_get( numror, jpdom_auto, 'e3t_b', e3t(:,:,:,Kbb), ldxios = lrxios )
-               CALL iom_get( numror, jpdom_auto, 'e3t_n', e3t(:,:,:,Kmm), ldxios = lrxios )
+               CALL iom_get( numror, jpdom_auto, 'e3t_b', e3t(:,:,:,Kbb) )
+               CALL iom_get( numror, jpdom_auto, 'e3t_n', e3t(:,:,:,Kmm) )
                ! needed to restart if land processor not computed 
                IF(lwp) write(numout,*) 'dom_vvl_rst : e3t(:,:,:,Kbb) and e3t(:,:,:,Kmm) found in restart files'
@@ -814,5 +813,5 @@
                IF(lwp) write(numout,*) 'e3t_n set equal to e3t_b.'
                IF(lwp) write(numout,*) 'l_1st_euler is forced to true'
-               CALL iom_get( numror, jpdom_auto, 'e3t_b', e3t(:,:,:,Kbb), ldxios = lrxios )
+               CALL iom_get( numror, jpdom_auto, 'e3t_b', e3t(:,:,:,Kbb) )
                e3t(:,:,:,Kmm) = e3t(:,:,:,Kbb)
                l_1st_euler = .true.
@@ -821,5 +820,5 @@
                IF(lwp) write(numout,*) 'e3t_b set equal to e3t_n.'
                IF(lwp) write(numout,*) 'l_1st_euler is forced to true'
-               CALL iom_get( numror, jpdom_auto, 'e3t_n', e3t(:,:,:,Kmm), ldxios = lrxios )
+               CALL iom_get( numror, jpdom_auto, 'e3t_n', e3t(:,:,:,Kmm) )
                e3t(:,:,:,Kbb) = e3t(:,:,:,Kmm)
                l_1st_euler = .true.
@@ -846,6 +845,6 @@
                !                          ! ----------------------- !
                IF( MIN( id3, id4 ) > 0 ) THEN  ! all required arrays exist
-                  CALL iom_get( numror, jpdom_auto, 'tilde_e3t_b', tilde_e3t_b(:,:,:), ldxios = lrxios )
-                  CALL iom_get( numror, jpdom_auto, 'tilde_e3t_n', tilde_e3t_n(:,:,:), ldxios = lrxios )
+                  CALL iom_get( numror, jpdom_auto, 'tilde_e3t_b', tilde_e3t_b(:,:,:) )
+                  CALL iom_get( numror, jpdom_auto, 'tilde_e3t_n', tilde_e3t_n(:,:,:) )
                ELSE                            ! one at least array is missing
                   tilde_e3t_b(:,:,:) = 0.0_wp
@@ -856,5 +855,5 @@
                   !                       ! ------------ !
                   IF( id5 > 0 ) THEN  ! required array exists
-                     CALL iom_get( numror, jpdom_auto, 'hdiv_lf', hdiv_lf(:,:,:), ldxios = lrxios )
+                     CALL iom_get( numror, jpdom_auto, 'hdiv_lf', hdiv_lf(:,:,:) )
                   ELSE                ! array is missing
                      hdiv_lf(:,:,:) = 0.0_wp
@@ -862,5 +861,4 @@
                ENDIF
             ENDIF
-            IF( lrxios ) CALL iom_swap( cxios_context )
             !
          ELSE                                   !* Initialize at "rest"
@@ -931,23 +929,21 @@
          !                                   ! ===================
          IF(lwp) WRITE(numout,*) '---- dom_vvl_rst ----'
-         IF( lwxios ) CALL iom_swap(      cw_ocerst_cxt          )
          !                                           ! --------- !
          !                                           ! all cases !
          !                                           ! --------- !
-         CALL iom_rstput( kt, nitrst, numrow, 'e3t_b', e3t(:,:,:,Kbb), ldxios = lwxios )
-         CALL iom_rstput( kt, nitrst, numrow, 'e3t_n', e3t(:,:,:,Kmm), ldxios = lwxios )
+         CALL iom_rstput( kt, nitrst, numrow, 'e3t_b', e3t(:,:,:,Kbb) )
+         CALL iom_rstput( kt, nitrst, numrow, 'e3t_n', e3t(:,:,:,Kmm) )
          !                                           ! ----------------------- !
          IF( ln_vvl_ztilde .OR. ln_vvl_layer ) THEN  ! z_tilde and layer cases !
             !                                        ! ----------------------- !
-            CALL iom_rstput( kt, nitrst, numrow, 'tilde_e3t_b', tilde_e3t_b(:,:,:), ldxios = lwxios)
-            CALL iom_rstput( kt, nitrst, numrow, 'tilde_e3t_n', tilde_e3t_n(:,:,:), ldxios = lwxios)
+            CALL iom_rstput( kt, nitrst, numrow, 'tilde_e3t_b', tilde_e3t_b(:,:,:))
+            CALL iom_rstput( kt, nitrst, numrow, 'tilde_e3t_n', tilde_e3t_n(:,:,:))
          END IF
          !                                           ! -------------!    
          IF( ln_vvl_ztilde ) THEN                    ! z_tilde case !
             !                                        ! ------------ !
-            CALL iom_rstput( kt, nitrst, numrow, 'hdiv_lf', hdiv_lf(:,:,:), ldxios = lwxios)
+            CALL iom_rstput( kt, nitrst, numrow, 'hdiv_lf', hdiv_lf(:,:,:))
          ENDIF
          !
-         IF( lwxios ) CALL iom_swap(      cxios_context          )
       ENDIF
       !
