Index: /NEMO/trunk/src/ABL/ablrst.F90
===================================================================
--- /NEMO/trunk/src/ABL/ablrst.F90	(revision 12648)
+++ /NEMO/trunk/src/ABL/ablrst.F90	(revision 12649)
@@ -74,5 +74,5 @@
             ENDIF
             !
-            CALL iom_open( TRIM(clpath)//TRIM(clname), numraw, ldwrt = .TRUE., kdlev = jpka )
+            CALL iom_open( TRIM(clpath)//TRIM(clname), numraw, ldwrt = .TRUE., kdlev = jpka, cdcomp = 'ABL' )
             lrst_abl = .TRUE.
          ENDIF
@@ -146,5 +146,5 @@
       ENDIF
 
-      CALL iom_open ( TRIM(cn_ablrst_indir)//'/'//cn_ablrst_in, numrar, kdlev = jpka )
+      CALL iom_open ( TRIM(cn_ablrst_indir)//'/'//cn_ablrst_in, numrar )
 
       ! Time info
Index: /NEMO/trunk/src/ICE/icectl.F90
===================================================================
--- /NEMO/trunk/src/ICE/icectl.F90	(revision 12648)
+++ /NEMO/trunk/src/ICE/icectl.F90	(revision 12649)
@@ -331,5 +331,5 @@
       IF(lwp) WRITE(numout,*)                
 
-      CALL iom_open( TRIM(cdfile_name), inum, ldwrt = .TRUE., kdlev = jpl )
+      CALL iom_open( TRIM(cdfile_name), inum, ldwrt = .TRUE., kdlev = jpl, cdcomp = 'ICE' )
       
       CALL iom_rstput( 0, 0, inum, 'cons_mass', pdiag_mass(:,:) , ktype = jp_r8 )    ! ice mass spurious lost/gain
Index: /NEMO/trunk/src/ICE/icerst.F90
===================================================================
--- /NEMO/trunk/src/ICE/icerst.F90	(revision 12648)
+++ /NEMO/trunk/src/ICE/icerst.F90	(revision 12649)
@@ -80,5 +80,5 @@
             ENDIF
             !
-            CALL iom_open( TRIM(clpath)//TRIM(clname), numriw, ldwrt = .TRUE., kdlev = jpl )
+            CALL iom_open( TRIM(clpath)//TRIM(clname), numriw, ldwrt = .TRUE., kdlev = jpl, cdcomp = 'ICE' )
             lrst_ice = .TRUE.
          ENDIF
@@ -185,5 +185,5 @@
       ENDIF
 
-      CALL iom_open ( TRIM(cn_icerst_indir)//'/'//cn_icerst_in, numrir, kdlev = jpl )
+      CALL iom_open ( TRIM(cn_icerst_indir)//'/'//cn_icerst_in, numrir )
 
       ! test if v_i exists 
Index: /NEMO/trunk/src/OCE/DIA/diawri.F90
===================================================================
--- /NEMO/trunk/src/OCE/DIA/diawri.F90	(revision 12648)
+++ /NEMO/trunk/src/OCE/DIA/diawri.F90	(revision 12649)
@@ -924,11 +924,7 @@
       IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~   and forcing fields file created '
       IF(lwp) WRITE(numout,*) '                and named :', cdfile_name, '...nc'
-
-#if defined key_si3
-     CALL iom_open( TRIM(cdfile_name), inum, ldwrt = .TRUE., kdlev = jpl )
-#else
-     CALL iom_open( TRIM(cdfile_name), inum, ldwrt = .TRUE. )
-#endif
-
+      !
+      CALL iom_open( TRIM(cdfile_name), inum, ldwrt = .TRUE. )
+      !
       CALL iom_rstput( 0, 0, inum, 'votemper', ts(:,:,:,jp_tem,Kmm) )    ! now temperature
       CALL iom_rstput( 0, 0, inum, 'vosaline', ts(:,:,:,jp_sal,Kmm) )    ! now salinity
@@ -943,5 +939,5 @@
       CALL iom_rstput( 0, 0, inum, 'risfdep', risfdep            )    ! now k-velocity
       CALL iom_rstput( 0, 0, inum, 'ht'     , ht                 )    ! now water column height
-
+      !
       IF ( ln_isf ) THEN
          IF (ln_isfcav_mlt) THEN
@@ -949,19 +945,19 @@
             CALL iom_rstput( 0, 0, inum, 'rhisf_cav_tbl', rhisf_tbl_cav    )    ! now k-velocity
             CALL iom_rstput( 0, 0, inum, 'rfrac_cav_tbl', rfrac_tbl_cav    )    ! now k-velocity
-            CALL iom_rstput( 0, 0, inum, 'misfkb_cav', REAL(misfkb_cav,8)    )    ! now k-velocity
-            CALL iom_rstput( 0, 0, inum, 'misfkt_cav', REAL(misfkt_cav,8)    )    ! now k-velocity
-            CALL iom_rstput( 0, 0, inum, 'mskisf_cav', REAL(mskisf_cav,8), ktype = jp_i1 )
+            CALL iom_rstput( 0, 0, inum, 'misfkb_cav', REAL(misfkb_cav,wp) )    ! now k-velocity
+            CALL iom_rstput( 0, 0, inum, 'misfkt_cav', REAL(misfkt_cav,wp) )    ! now k-velocity
+            CALL iom_rstput( 0, 0, inum, 'mskisf_cav', REAL(mskisf_cav,wp), ktype = jp_i1 )
          END IF
          IF (ln_isfpar_mlt) THEN
-            CALL iom_rstput( 0, 0, inum, 'isfmsk_par', REAL(mskisf_par,8)  )    ! now k-velocity
+            CALL iom_rstput( 0, 0, inum, 'isfmsk_par', REAL(mskisf_par,wp) )    ! now k-velocity
             CALL iom_rstput( 0, 0, inum, 'fwfisf_par', fwfisf_par          )    ! now k-velocity
             CALL iom_rstput( 0, 0, inum, 'rhisf_par_tbl', rhisf_tbl_par    )    ! now k-velocity
             CALL iom_rstput( 0, 0, inum, 'rfrac_par_tbl', rfrac_tbl_par    )    ! now k-velocity
-            CALL iom_rstput( 0, 0, inum, 'misfkb_par', REAL(misfkb_par,8)    )    ! now k-velocity
-            CALL iom_rstput( 0, 0, inum, 'misfkt_par', REAL(misfkt_par,8)    )    ! now k-velocity
-            CALL iom_rstput( 0, 0, inum, 'mskisf_par', REAL(mskisf_par,8), ktype = jp_i1 )
+            CALL iom_rstput( 0, 0, inum, 'misfkb_par', REAL(misfkb_par,wp) )    ! now k-velocity
+            CALL iom_rstput( 0, 0, inum, 'misfkt_par', REAL(misfkt_par,wp) )    ! now k-velocity
+            CALL iom_rstput( 0, 0, inum, 'mskisf_par', REAL(mskisf_par,wp), ktype = jp_i1 )
          END IF
       END IF
-
+      !
       IF( ALLOCATED(ahtu) ) THEN
          CALL iom_rstput( 0, 0, inum,  'ahtu', ahtu              )    ! aht at u-point
@@ -993,13 +989,15 @@
          CALL iom_rstput ( 0, 0, inum, "qz1_abl",  tq_abl(:,:,2,nt_a,2) )   ! now first level humidity
       ENDIF
- 
+      !
+      CALL iom_close( inum )
+      ! 
 #if defined key_si3
       IF( nn_ice == 2 ) THEN   ! condition needed in case agrif + ice-model but no-ice in child grid
+         CALL iom_open( TRIM(cdfile_name)//'_ice', inum, ldwrt = .TRUE., kdlev = jpl, cdcomp = 'ICE' )
          CALL ice_wri_state( inum )
+         CALL iom_close( inum )
       ENDIF
 #endif
-      !
-      CALL iom_close( inum )
-      ! 
+
    END SUBROUTINE dia_wri_state
 
Index: /NEMO/trunk/src/OCE/FLO/floblk.F90
===================================================================
--- /NEMO/trunk/src/OCE/FLO/floblk.F90	(revision 12648)
+++ /NEMO/trunk/src/OCE/FLO/floblk.F90	(revision 12649)
@@ -175,5 +175,5 @@
             zgidfl(jfl) = float(iioutfl(jfl) - iiinfl(jfl))
             IF( zufl(jfl)*zuoutfl <= 0. ) THEN
-               ztxfl(jfl) = 1.E99
+               ztxfl(jfl) = HUGE(1._wp)
             ELSE
                IF( ABS(zudfl(jfl)) >= 1.E-5 ) THEN
@@ -191,5 +191,5 @@
             zgjdfl(jfl) = float(ijoutfl(jfl)-ijinfl(jfl))
             IF( zvfl(jfl)*zvoutfl <= 0. ) THEN
-               ztyfl(jfl) = 1.E99
+               ztyfl(jfl) = HUGE(1._wp)
             ELSE
                IF( ABS(zvdfl(jfl)) >= 1.E-5 ) THEN
@@ -208,5 +208,5 @@
                zgkdfl(jfl) = float(ikoutfl(jfl) - ikinfl(jfl))
                IF( zwfl(jfl)*zwoutfl <= 0. ) THEN
-                  ztzfl(jfl) = 1.E99
+                  ztzfl(jfl) = HUGE(1._wp)
                ELSE
                   IF( ABS(zwdfl(jfl)) >= 1.E-5 ) THEN
Index: /NEMO/trunk/src/OCE/IOM/iom.F90
===================================================================
--- /NEMO/trunk/src/OCE/IOM/iom.F90	(revision 12648)
+++ /NEMO/trunk/src/OCE/IOM/iom.F90	(revision 12649)
@@ -664,5 +664,5 @@
 
 
-   SUBROUTINE iom_open( cdname, kiomid, ldwrt, kdom, ldstop, ldiof, kdlev )
+   SUBROUTINE iom_open( cdname, kiomid, ldwrt, kdom, ldstop, ldiof, kdlev, cdcomp )
       !!---------------------------------------------------------------------
       !!                   ***  SUBROUTINE  iom_open  ***
@@ -677,4 +677,5 @@
       LOGICAL         , INTENT(in   ), OPTIONAL ::   ldiof    ! Interp On the Fly, needed for AGRIF (default = .FALSE.)
       INTEGER         , INTENT(in   ), OPTIONAL ::   kdlev    ! number of vertical levels
+      CHARACTER(len=3), INTENT(in   ), OPTIONAL ::   cdcomp   ! name of component calling iom_nf90_open
       !
       CHARACTER(LEN=256)    ::   clname    ! the name of the file based on cdname [[+clcpu]+clcpu]
@@ -822,5 +823,5 @@
       ENDIF
       IF( istop == nstop ) THEN   ! no error within this routine
-         CALL iom_nf90_open( clname, kiomid, llwrt, llok, idompar, kdlev = kdlev )
+         CALL iom_nf90_open( clname, kiomid, llwrt, llok, idompar, kdlev = kdlev, cdcomp = cdcomp )
       ENDIF
       !
Index: /NEMO/trunk/src/OCE/IOM/iom_def.F90
===================================================================
--- /NEMO/trunk/src/OCE/IOM/iom_def.F90	(revision 12648)
+++ /NEMO/trunk/src/OCE/IOM/iom_def.F90	(revision 12649)
@@ -50,4 +50,5 @@
    TYPE, PUBLIC ::   file_descriptor
       CHARACTER(LEN=240)                        ::   name     !: name of the file
+      CHARACTER(LEN=3  )                        ::   comp     !: name of component opening the file ('OCE', 'ICE'...)
       INTEGER                                   ::   nfid     !: identifier of the file (0 if closed)
                                                               !: jpioipsl option has been removed)
@@ -64,5 +65,4 @@
       REAL(kind=wp), DIMENSION(jpmax_vars)      ::   scf      !: scale_factor of the variables
       REAL(kind=wp), DIMENSION(jpmax_vars)      ::   ofs      !: add_offset of the variables
-      INTEGER                                   ::   nlev     ! number of vertical levels
    END TYPE file_descriptor
    TYPE(file_descriptor), DIMENSION(jpmax_files), PUBLIC ::   iom_file !: array containing the info for all opened files
Index: /NEMO/trunk/src/OCE/IOM/iom_nf90.F90
===================================================================
--- /NEMO/trunk/src/OCE/IOM/iom_nf90.F90	(revision 12648)
+++ /NEMO/trunk/src/OCE/IOM/iom_nf90.F90	(revision 12649)
@@ -19,5 +19,5 @@
    !!----------------------------------------------------------------------
    USE dom_oce         ! ocean space and time domain
-   USE sbc_oce, ONLY: jpka, ght_abl ! abl vertical level number and height
+   USE sbc_oce, ONLY: ght_abl ! abl vertical level number and height
    USE lbclnk          ! lateal boundary condition / mpp exchanges
    USE iom_def         ! iom variables definitions
@@ -46,5 +46,5 @@
 CONTAINS
 
-   SUBROUTINE iom_nf90_open( cdname, kiomid, ldwrt, ldok, kdompar, kdlev )
+   SUBROUTINE iom_nf90_open( cdname, kiomid, ldwrt, ldok, kdompar, kdlev, cdcomp )
       !!---------------------------------------------------------------------
       !!                   ***  SUBROUTINE  iom_open  ***
@@ -58,7 +58,9 @@
       INTEGER, DIMENSION(2,5), INTENT(in   ), OPTIONAL ::   kdompar     ! domain parameters: 
       INTEGER                , INTENT(in   ), OPTIONAL ::   kdlev       ! size of the ice/abl third dimension
+      CHARACTER(len=3)       , INTENT(in   ), OPTIONAL ::   cdcomp      ! name of component calling iom_nf90_open
 
       CHARACTER(LEN=256) ::   clinfo           ! info character
       CHARACTER(LEN=256) ::   cltmp            ! temporary character
+      CHARACTER(LEN=3  ) ::   clcomp           ! name of component calling iom_nf90_open
       INTEGER            ::   iln              ! lengths of character
       INTEGER            ::   istop            ! temporary storage of nstop
@@ -70,5 +72,4 @@
       INTEGER            ::   ihdf5            ! local variable for retrieval of value for NF90_HDF5
       LOGICAL            ::   llclobber        ! local definition of ln_clobber
-      INTEGER            ::   ilevels          ! vertical levels
       !---------------------------------------------------------------------
       !
@@ -77,6 +78,9 @@
       !
       !                 !number of vertical levels
-      IF( PRESENT(kdlev) )   THEN   ;   ilevels = kdlev    ! use input value (useful for sea-ice and abl)
-      ELSE                          ;   ilevels = jpk      ! by default jpk
+      IF( PRESENT(cdcomp) )   THEN
+         IF( .NOT. PRESENT(kdlev) ) CALL ctl_stop( 'iom_nf90_open: cdcomp and kdlev must both be present' )
+         clcomp = cdcomp    ! use input value
+      ELSE
+         clcomp = 'OCE'     ! by default 
       ENDIF
       !
@@ -125,19 +129,14 @@
             CALL iom_nf90_check(NF90_SET_FILL( if90id, NF90_NOFILL,                   idmy ), clinfo)
             ! define dimensions
-            CALL iom_nf90_check(NF90_DEF_DIM( if90id,            'x',   kdompar(1,1), idmy ), clinfo)
-            CALL iom_nf90_check(NF90_DEF_DIM( if90id,            'y',   kdompar(2,1), idmy ), clinfo)
-            IF( PRESENT(kdlev) ) THEN
-              IF( kdlev == jpka ) THEN
-                 CALL iom_nf90_check(NF90_DEF_DIM( if90id, 'nav_lev',          kdlev, idmy ), clinfo)
-                 CALL iom_nf90_check(NF90_DEF_DIM( if90id, 'time_counter', NF90_UNLIMITED, idmy ), clinfo)
-              ELSE
-                 CALL iom_nf90_check(NF90_DEF_DIM( if90id, 'nav_lev',            jpk, idmy ), clinfo)
-                 CALL iom_nf90_check(NF90_DEF_DIM( if90id, 'time_counter', NF90_UNLIMITED, idmy ), clinfo)
-                 CALL iom_nf90_check(NF90_DEF_DIM( if90id,  'numcat',          kdlev, idmy ), clinfo)
-              ENDIF
-            ELSE
-               CALL iom_nf90_check(NF90_DEF_DIM( if90id, 'nav_lev',            jpk, idmy ), clinfo)
-               CALL iom_nf90_check(NF90_DEF_DIM( if90id, 'time_counter', NF90_UNLIMITED, idmy ), clinfo)
-            ENDIF
+                               CALL iom_nf90_check(NF90_DEF_DIM( if90id,            'x',   kdompar(1,1), idmy ), clinfo)
+                               CALL iom_nf90_check(NF90_DEF_DIM( if90id,            'y',   kdompar(2,1), idmy ), clinfo)
+            SELECT CASE (clcomp)
+            CASE ('OCE')   ;   CALL iom_nf90_check(NF90_DEF_DIM( if90id,      'nav_lev',            jpk, idmy ), clinfo)
+            CASE ('ICE')   ;   CALL iom_nf90_check(NF90_DEF_DIM( if90id,       'numcat',          kdlev, idmy ), clinfo)
+            CASE ('ABL')   ;   CALL iom_nf90_check(NF90_DEF_DIM( if90id,      'nav_lev',          kdlev, idmy ), clinfo)
+            CASE ('SED')   ;   CALL iom_nf90_check(NF90_DEF_DIM( if90id,       'numsed',          kdlev, idmy ), clinfo)
+            CASE DEFAULT   ;   CALL ctl_stop( 'iom_nf90_open unknown component type' )
+            END SELECT
+                               CALL iom_nf90_check(NF90_DEF_DIM( if90id, 'time_counter', NF90_UNLIMITED, idmy ), clinfo)
             ! global attributes
             CALL iom_nf90_check(NF90_PUT_ATT( if90id, NF90_GLOBAL, 'DOMAIN_number_total'   , jpnij              ), clinfo)
@@ -165,8 +164,8 @@
          ENDDO
          iom_file(kiomid)%name   = TRIM(cdname)
+         iom_file(kiomid)%comp   = clcomp
          iom_file(kiomid)%nfid   = if90id
          iom_file(kiomid)%nvars  = 0
          iom_file(kiomid)%irec   = -1   ! useless for NetCDF files, used to know if the file is in define mode 
-         iom_file(kiomid)%nlev   = ilevels
          CALL iom_nf90_check(NF90_Inquire(if90id, unlimitedDimId = iom_file(kiomid)%iduld), clinfo)
          IF( iom_file(kiomid)%iduld .GE. 0 ) THEN
@@ -529,7 +528,5 @@
       INTEGER, DIMENSION(4) :: idimid               ! dimensions id
       CHARACTER(LEN=256)    :: clinfo               ! info character
-      CHARACTER(LEN= 12), DIMENSION(5) :: cltmp     ! temporary character
       INTEGER               :: if90id               ! nf90 file identifier
-      INTEGER               :: idmy                 ! dummy variable
       INTEGER               :: itype                ! variable type
       INTEGER, DIMENSION(4) :: ichunksz             ! NetCDF4 chunk sizes. Will be computed using
@@ -540,5 +537,4 @@
       !                                             ! when appropriate (currently chunking is applied to 4d fields only)
       INTEGER               :: idlv                 ! local variable
-      INTEGER               :: idim3                ! id of the third dimension
       !---------------------------------------------------------------------
       !
@@ -554,24 +550,20 @@
          ENDIF
          ! define the dimension variables if it is not already done
-         ! Warning: we must use the same character length in an array constructor (at least for gcc compiler)
-         cltmp = (/ 'nav_lon     ', 'nav_lat     ', 'nav_lev     ', 'time_counter', 'numcat      ' /)   
-         CALL iom_nf90_check(NF90_DEF_VAR( if90id, TRIM(cltmp(1)), NF90_FLOAT , (/ 1, 2 /), iom_file(kiomid)%nvid(1) ), clinfo)
-         CALL iom_nf90_check(NF90_DEF_VAR( if90id, TRIM(cltmp(2)), NF90_FLOAT , (/ 1, 2 /), iom_file(kiomid)%nvid(2) ), clinfo)
-         CALL iom_nf90_check(NF90_DEF_VAR( if90id, TRIM(cltmp(3)), NF90_FLOAT , (/ 3    /), iom_file(kiomid)%nvid(3) ), clinfo)
-         CALL iom_nf90_check(NF90_DEF_VAR( if90id, TRIM(cltmp(4)), NF90_DOUBLE, (/ 4    /), iom_file(kiomid)%nvid(4) ), clinfo)
+         DO jd = 1, 2
+            CALL iom_nf90_check(NF90_INQUIRE_DIMENSION(if90id,jd,iom_file(kiomid)%cn_var(jd),iom_file(kiomid)%dimsz(jd,jd)),clinfo)
+            CALL iom_nf90_check(NF90_DEF_VAR( if90id, TRIM(iom_file(kiomid)%cn_var(jd)), NF90_FLOAT , (/ 1, 2 /),   &
+               &                              iom_file(kiomid)%nvid(jd) ), clinfo)
+         END DO
+         iom_file(kiomid)%dimsz(2,1) = iom_file(kiomid)%dimsz(2,2)   ! second dim of first  variable
+         iom_file(kiomid)%dimsz(1,2) = iom_file(kiomid)%dimsz(1,1)   ! first  dim of second variable
+         DO jd = 3, 4
+            CALL iom_nf90_check(NF90_INQUIRE_DIMENSION(if90id,jd,iom_file(kiomid)%cn_var(jd),iom_file(kiomid)%dimsz(1,jd)), clinfo)
+            CALL iom_nf90_check(NF90_DEF_VAR( if90id, TRIM(iom_file(kiomid)%cn_var(jd)), NF90_FLOAT , (/ jd   /),   &
+               &                              iom_file(kiomid)%nvid(jd) ), clinfo)
+         END DO
          ! update informations structure related the dimension variable we just added...
          iom_file(kiomid)%nvars       = 4
          iom_file(kiomid)%luld(1:4)   = (/ .FALSE., .FALSE., .FALSE., .TRUE. /)
-         iom_file(kiomid)%cn_var(1:4) = cltmp(1:4)
          iom_file(kiomid)%ndims(1:4)  = (/ 2, 2, 1, 1 /)
-         IF( NF90_INQ_DIMID( if90id, 'numcat', idmy ) == nf90_noerr ) THEN   ! add a 5th variable corresponding to the 5th dimension
-            CALL iom_nf90_check(NF90_DEF_VAR( if90id, TRIM(cltmp(5)), NF90_FLOAT , (/ 5 /), iom_file(kiomid)%nvid(5) ), clinfo)
-            iom_file(kiomid)%nvars     = 5
-            iom_file(kiomid)%luld(5)   = .FALSE.
-            iom_file(kiomid)%cn_var(5) = cltmp(5)
-            iom_file(kiomid)%ndims(5)  = 1
-         ENDIF
-         ! trick: defined to 0 to say that dimension variables are defined but not yet written
-         iom_file(kiomid)%dimsz(1, 1)  = 0   
          IF(lwp) WRITE(numout,*) TRIM(clinfo)//' define dimension variables done'
       ENDIF
@@ -594,14 +586,8 @@
          IF(     PRESENT(pv_r0d) ) THEN   ;   idims = 0
          ELSEIF( PRESENT(pv_r1d) ) THEN
-            IF(( SIZE(pv_r1d,1) == jpk ).OR.( SIZE(pv_r1d,1) == jpka )) THEN   ;   idim3 = 3
-            ELSE                                                               ;   idim3 = 5
-            ENDIF
-                                              idims = 2   ;   idimid(1:idims) = (/idim3,4/)
-         ELSEIF( PRESENT(pv_r2d) ) THEN   ;   idims = 3   ;   idimid(1:idims) = (/1,2  ,4/)
+                                              idims = 2   ;   idimid(1:idims) = (/3,4/)
+         ELSEIF( PRESENT(pv_r2d) ) THEN   ;   idims = 3   ;   idimid(1:idims) = (/1,2,4/)
          ELSEIF( PRESENT(pv_r3d) ) THEN
-            IF(( SIZE(pv_r3d,3) == jpk ).OR.( SIZE(pv_r3d,3) == jpka )) THEN   ;   idim3 = 3
-            ELSE                                                               ;   idim3 = 5
-            ENDIF
-                                              idims = 4   ;   idimid(1:idims) = (/1,2,idim3,4/)
+                                              idims = 4   ;   idimid(1:idims) = (/1,2,3,4/)
          ENDIF
          IF( PRESENT(ktype) ) THEN   ! variable external type
@@ -678,25 +664,19 @@
             ! =============
             ! trick: is defined to 0 => dimension variable are defined but not yet written
-            IF( iom_file(kiomid)%dimsz(1, 1) == 0 ) THEN
-               CALL iom_nf90_check( NF90_INQ_VARID( if90id, 'nav_lon'     , idmy )         , clinfo )
-               CALL iom_nf90_check( NF90_PUT_VAR  ( if90id, idmy, glamt(ix1:ix2, iy1:iy2) ), clinfo )
-               CALL iom_nf90_check( NF90_INQ_VARID( if90id, 'nav_lat'     , idmy )         , clinfo )
-               CALL iom_nf90_check( NF90_PUT_VAR  ( if90id, idmy, gphit(ix1:ix2, iy1:iy2) ), clinfo )
-               CALL iom_nf90_check( NF90_INQ_VARID( if90id, 'nav_lev'     , idmy ), clinfo )
-               IF (iom_file(kiomid)%nlev == jpka) THEN   ;   CALL iom_nf90_check( NF90_PUT_VAR  ( if90id, idmy,  ght_abl), clinfo )
-               ELSE                                      ;   CALL iom_nf90_check( NF90_PUT_VAR  ( if90id, idmy, gdept_1d), clinfo )
-               ENDIF
-               IF( NF90_INQ_VARID( if90id, 'numcat', idmy ) == nf90_noerr ) THEN
-                  CALL iom_nf90_check( NF90_PUT_VAR  ( if90id, idmy, (/ (idlv, idlv = 1,iom_file(kiomid)%nlev) /)), clinfo )
-               ENDIF
-               ! +++ WRONG VALUE: to be improved but not really useful...
-               CALL iom_nf90_check( NF90_INQ_VARID( if90id, 'time_counter', idmy ), clinfo )
-               CALL iom_nf90_check( NF90_PUT_VAR( if90id, idmy, kt                      ), clinfo )   
-               ! update the values of the variables dimensions size
-               CALL iom_nf90_check( NF90_INQUIRE_DIMENSION( if90id, 1, len = iom_file(kiomid)%dimsz(1,1) ), clinfo )
-               CALL iom_nf90_check( NF90_INQUIRE_DIMENSION( if90id, 2, len = iom_file(kiomid)%dimsz(2,1) ), clinfo )
-               iom_file(kiomid)%dimsz(1:2, 2) = iom_file(kiomid)%dimsz(1:2, 1)
-               CALL iom_nf90_check( NF90_INQUIRE_DIMENSION( if90id, 3, len = iom_file(kiomid)%dimsz(1,3) ), clinfo )
-               iom_file(kiomid)%dimsz(1  , 4) = 1   ! unlimited dimension
+            IF( iom_file(kiomid)%dimsz(1, 4) == 0 ) THEN   ! time_counter = 0
+               CALL iom_nf90_check(    NF90_PUT_VAR( if90id, 1,                            glamt(ix1:ix2, iy1:iy2) ), clinfo )
+               CALL iom_nf90_check(    NF90_PUT_VAR( if90id, 2,                            gphit(ix1:ix2, iy1:iy2) ), clinfo )
+               SELECT CASE (iom_file(kiomid)%comp)
+               CASE ('OCE')  
+                  CALL iom_nf90_check( NF90_PUT_VAR( if90id, 3,                                           gdept_1d ), clinfo )
+               CASE ('ABL')
+                  CALL iom_nf90_check( NF90_PUT_VAR( if90id, 3,                                            ght_abl ), clinfo )
+               CASE DEFAULT
+                  CALL iom_nf90_check( NF90_PUT_VAR( if90id, 3, (/ (idlv, idlv = 1,iom_file(kiomid)%dimsz(1,3)) /) ), clinfo )
+               END SELECT
+               ! "wrong" value: to be improved but not really useful...
+               CALL iom_nf90_check(   NF90_PUT_VAR( if90id, 4,                                                  kt ), clinfo )   
+               ! update the size of the variable corresponding to the unlimited dimension
+               iom_file(kiomid)%dimsz(1, 4) = 1   ! so we don't enter this IF case any more...
                IF(lwp) WRITE(numout,*) TRIM(clinfo)//' write dimension variables done'
             ENDIF
Index: /NEMO/trunk/src/OCE/STO/storng.F90
===================================================================
--- /NEMO/trunk/src/OCE/STO/storng.F90	(revision 12648)
+++ /NEMO/trunk/src/OCE/STO/storng.F90	(revision 12649)
@@ -50,5 +50,4 @@
 
    ! Parameters to generate real random variates
-   REAL(KIND=wp), PARAMETER :: huge64=9223372036854775808.0  ! +1
    REAL(KIND=wp), PARAMETER :: zero=0.0, half=0.5, one=1.0, two=2.0
 
@@ -275,5 +274,5 @@
       REAL(KIND=wp) :: uran
 
-      uran = half * ( one + REAL(kiss(),wp) / huge64 )
+      uran = half * ( one + REAL(kiss(),wp) / HUGE(1._wp) )
 
    END SUBROUTINE kiss_uniform
@@ -298,6 +297,6 @@
          rsq = two
          DO WHILE ( (rsq.GE.one).OR. (rsq.EQ.zero) )
-            u1 = REAL(kiss(),wp) / huge64
-            u2 = REAL(kiss(),wp) / huge64
+            u1 = REAL(kiss(),wp) / HUGE(1._wp)
+            u2 = REAL(kiss(),wp) / HUGE(1._wp)
             rsq = u1*u1 + u2*u2
          ENDDO
Index: /NEMO/trunk/src/SAS/diawri.F90
===================================================================
--- /NEMO/trunk/src/SAS/diawri.F90	(revision 12648)
+++ /NEMO/trunk/src/SAS/diawri.F90	(revision 12649)
@@ -438,11 +438,7 @@
       IF(lwp) WRITE(numout,*) '~~~~~~~~~~~~~   and forcing fields file created '
       IF(lwp) WRITE(numout,*) '                and named :', cdfile_name, '...nc'
-
-#if defined key_si3
-     CALL iom_open( TRIM(cdfile_name), inum, ldwrt = .TRUE., kdlev = jpl )
-#else
-     CALL iom_open( TRIM(cdfile_name), inum, ldwrt = .TRUE. )
-#endif
-
+      !
+      CALL iom_open( TRIM(cdfile_name), inum, ldwrt = .TRUE. )
+      !
       CALL iom_rstput( 0, 0, inum, 'votemper', ts (:,:,:,jp_tem,Kmm) )    ! now temperature
       CALL iom_rstput( 0, 0, inum, 'vosaline', ts (:,:,:,jp_sal,Kmm) )    ! now salinity
@@ -457,13 +453,15 @@
       CALL iom_rstput( 0, 0, inum, 'sozotaux', utau                  )    ! i-wind stress
       CALL iom_rstput( 0, 0, inum, 'sometauy', vtau                  )    ! j-wind stress
- 
+      !
+      CALL iom_close( inum )
+      !
 #if defined key_si3
       IF( nn_ice == 2 ) THEN   ! condition needed in case agrif + ice-model but no-ice in child grid
+         CALL iom_open( TRIM(cdfile_name)//'_ice', inum, ldwrt = .TRUE., kdlev = jpl, cdcomp = 'ICE' )
          CALL ice_wri_state( inum )
-      ENDIF
-#endif
-      !
-      CALL iom_close( inum )
-      !
+         CALL iom_close( inum )
+      ENDIF
+#endif
+
    END SUBROUTINE dia_wri_state
 
Index: /NEMO/trunk/src/TOP/PISCES/SED/sedrst.F90
===================================================================
--- /NEMO/trunk/src/TOP/PISCES/SED/sedrst.F90	(revision 12648)
+++ /NEMO/trunk/src/TOP/PISCES/SED/sedrst.F90	(revision 12649)
@@ -80,5 +80,5 @@
          IF(lwp) WRITE(numsed,*) &
              '             open sed restart.output NetCDF file: ',TRIM(clpath)//clname
-         CALL iom_open( TRIM(clpath)//TRIM(clname), numrsw, ldwrt = .TRUE., kdlev = jpksed )
+         CALL iom_open( TRIM(clpath)//TRIM(clname), numrsw, ldwrt = .TRUE., kdlev = jpksed, cdcomp = 'SED' )
          lrst_sed = .TRUE.
       ENDIF
