Index: branches/UKMO/dev_r5518_AMM15_package/NEMOGCM/TOOLS/SIREN/src/iom_cdf.f90
===================================================================
--- branches/UKMO/dev_r5518_AMM15_package/NEMOGCM/TOOLS/SIREN/src/iom_cdf.f90	(revision 10248)
+++ branches/UKMO/dev_r5518_AMM15_package/NEMOGCM/TOOLS/SIREN/src/iom_cdf.f90	(revision 10251)
@@ -144,24 +144,16 @@
    !>
    !> @author J.Paul
-   !> @date November, 2013 - Initial Version
-   !> @date May, 2015 - add optional message to netcdf error message
-   !>
+   !> - November, 2013- Initial Version
+   !
    !> @param[in] id_status error status
-   !> @param[in] cd_msg    message
-   !-------------------------------------------------------------------
-   SUBROUTINE iom_cdf__check(id_status, cd_msg)
-      IMPLICIT NONE
-      ! Argument      
-      INTEGER(i4)     , INTENT(IN)           :: id_status
-      CHARACTER(LEN=*), INTENT(IN), OPTIONAL :: cd_msg
-      ! local variable
-      CHARACTER(LEN=lc) :: cl_msg
-      !----------------------------------------------------------------
-
-      cl_msg=""
-      IF( PRESENT(cd_msg) ) cl_msg=cd_msg
+   !-------------------------------------------------------------------
+   SUBROUTINE iom_cdf__check(id_status)
+      IMPLICIT NONE
+      ! Argument      
+      INTEGER(i4), INTENT(IN) :: id_status
+      !----------------------------------------------------------------
 
       IF( id_status /= NF90_NOERR )THEN
-         CALL logger_error(TRIM(cl_msg)//TRIM(NF90_STRERROR(id_status)))
+         CALL logger_error(TRIM(NF90_STRERROR(id_status)))
       ENDIF
 
@@ -181,5 +173,5 @@
    !>
    !> @author J.Paul
-   !> @date November, 2013 - Initial Version
+   !> - November, 2013- Initial Version
    !
    !> @param[inout] td_file   file structure
@@ -211,9 +203,8 @@
             CALL logger_info( " IOM CDF CREATE: file "//TRIM(td_file%c_name) )
 
-            il_status = NF90_CREATE(TRIM(td_file%c_name),&
-            &                       cmode=NF90_64BIT_OFFSET,&
-            &                       ncid=td_file%i_id)
-         !NF90_WRITE,               &
-            CALL iom_cdf__check(il_status," IOM CDF CREATE: ")
+            il_status = NF90_CREATE( TRIM(td_file%c_name),&
+            &                        NF90_WRITE,               &
+            &                        td_file%i_id)
+            CALL iom_cdf__check(il_status)
 
             td_file%l_def=.TRUE.
@@ -237,8 +228,7 @@
                &                      NF90_NOWRITE,         &
                &                      td_file%i_id)
-               CALL iom_cdf__check(il_status," IOM CDF OPEN: ")
-
-               CALL logger_trace("IOM CDF OPEN "//TRIM(td_file%c_name)//" "//&
-                  &  TRIM(fct_str(td_file%i_id)))
+               CALL iom_cdf__check(il_status)
+
+               CALL logger_trace("IOM CDF OPEN "//TRIM(td_file%c_name)//" "//TRIM(fct_str(td_file%i_id)))
             ELSE
 
@@ -249,5 +239,5 @@
                &                      NF90_WRITE,           &
                &                      td_file%i_id)
-               CALL iom_cdf__check(il_status,"IOM CDF OPEN: ")
+               CALL iom_cdf__check(il_status)
 
             ENDIF
@@ -277,5 +267,5 @@
    !>
    !> @author J.Paul
-   !> @date November, 2013 - Initial Version
+   !> - November, 2013- Initial Version
    !
    !> @param[inout] td_file   file structure
@@ -301,5 +291,5 @@
 
          il_status = NF90_CLOSE(td_file%i_id)
-         CALL iom_cdf__check(il_status,"IOM CDF CLOSE: ")
+         CALL iom_cdf__check(il_status)
 
          td_file%i_id = 0
@@ -317,5 +307,5 @@
    !>
    !> @author J.Paul
-   !> @date November, 2013 - Initial Version
+   !> - November, 2013- Initial Version
    !
    !> @param[inout] td_file   file structure
@@ -336,5 +326,5 @@
       il_status=NF90_INQUIRE(td_file%i_id, td_file%i_ndim, &
       &     td_file%i_nvar, td_file%i_natt, td_file%i_uldid, il_fmt)
-      CALL iom_cdf__check(il_status,"IOM CDF GET INFO: ")
+      CALL iom_cdf__check(il_status)
 
       SELECT CASE(il_fmt)
@@ -355,5 +345,5 @@
    !
    !> @author J.Paul
-   !> @date November, 2013 - Initial Version
+   !> - November, 2013- Initial Version
    !
    !> @param[inout] td_file   file structure
@@ -406,5 +396,5 @@
    !
    !> @author J.Paul
-   !> @date November, 2013 - Initial Version
+   !> - November, 2013- Initial Version
    !> @date September, 2014
    !> - use attribute periodicity read from the file if present.
@@ -449,5 +439,5 @@
    !
    !> @author J.Paul
-   !> @date November, 2013 - Initial Version
+   !> - November, 2013- Initial Version
    !
    !> @param[inout] td_file   file structure
@@ -490,12 +480,12 @@
 
             ! look for depth id
-            IF( INDEX(TRIM(fct_lower(td_file%t_var(ji)%c_name)),'depth')/=0 )THEN
+            IF( INDEX(TRIM(td_file%t_var(ji)%c_name),'depth') /= 0 )THEN
                IF( td_file%i_depthid == 0 )THEN
                   td_file%i_depthid=ji
                ELSE
                   IF( td_file%i_depthid /= ji )THEN
-                     CALL logger_error("IOM CDF GET FILE VAR: find more"//&
-                        &  " than one depth variable in file "//&
-                        &  TRIM(td_file%c_name) )
+                     CALL logger_error("IOM CDF GET FILE VAR: find more than one "//&
+                     &                 "depth variable in file "//&
+                     &                 TRIM(td_file%c_name) )
                   ENDIF
                ENDIF
@@ -503,5 +493,5 @@
 
             ! look for time id
-            IF( INDEX(TRIM(fct_lower(td_file%t_var(ji)%c_name)),'time')/=0 )THEN
+            IF( INDEX(TRIM(td_file%t_var(ji)%c_name),'time') /= 0 )THEN
                IF( td_file%i_timeid == 0 )THEN
                   td_file%i_timeid=ji
@@ -514,6 +504,7 @@
                      td_file%i_timeid=ji
                   !ELSE
-                  !   CALL logger_error("IOM CDF GET FILE VAR: find more "//&
-                  !   &                 "than one time variable in file "//&
+                  !   print *,'error'
+                  !   CALL logger_error("IOM OPEN: find more than one "//&
+                  !   &                 "time variable in file "//&
                   !   &                 TRIM(td_file%c_name) )
                   ENDIF
@@ -535,5 +526,5 @@
    !
    !> @author J.Paul
-   !> @date November, 2013 - Initial Version
+   !> - November, 2013- Initial Version
    !
    !> @param[inout] td_file   file structure
@@ -576,7 +567,5 @@
    !
    !> @author J.Paul
-   !> @date November, 2013 - Initial Version
-   !> @date February, 2015 - create unused dimension, when reading dimension
-   !> of length less or equal to zero
+   !> - November, 2013- Initial Version
    !
    !> @param[in] td_file   file structure
@@ -594,5 +583,4 @@
       INTEGER(i4)       :: il_len
       CHARACTER(LEN=lc) :: cl_name
-      LOGICAL           :: ll_use
       !----------------------------------------------------------------
 
@@ -613,15 +601,7 @@
          il_status=NF90_INQUIRE_DIMENSION(td_file%i_id, id_dimid, &
          &                                cl_name, il_len )
-         CALL iom_cdf__check(il_status,"IOM CDF READ DIM: ")
-
-         ll_use=.TRUE.
-         IF( il_len <= 0 )THEN
-            CALL logger_warn( &
-         &  " IOM CDF READ DIM: dimension "//TRIM(fct_str(id_dimid))//&
-         &  " in file "//TRIM(td_file%c_name)//" is less or equel to zero")
-            il_len=1
-            ll_use=.FALSE.
-         ENDIF
-         iom_cdf__read_dim_id=dim_init(cl_name, il_len, ld_use=ll_use)
+         CALL iom_cdf__check(il_status)
+
+         iom_cdf__read_dim_id=dim_init(cl_name, il_len)
 
       ENDIF
@@ -633,5 +613,5 @@
    !
    !> @author J.Paul
-   !> @date November, 2013 - Initial Version
+   !> - November, 2013- Initial Version
    !
    !> @param[in] td_file   file structure
@@ -654,6 +634,5 @@
 
          CALL logger_error( &
-         &  " IOM CDF READ DIM: no id associated to file "//&
-         &  TRIM(td_file%c_name))
+         &  " IOM CDF READ DIM: no id associated to file "//TRIM(td_file%c_name))
 
       ELSE      
@@ -661,5 +640,5 @@
          il_status=NF90_INQ_DIMID( td_file%i_id, TRIM(ADJUSTL(cd_name)), &
          &                         il_dimid)
-         CALL iom_cdf__check(il_status,"IOM CDF READ DIM: ")
+         CALL iom_cdf__check(il_status)
 
          iom_cdf__read_dim_name=iom_cdf_read_dim(td_file, il_dimid)
@@ -673,5 +652,5 @@
    !
    !> @author J.Paul
-   !> @date November, 2013 - Initial Version
+   !> - November, 2013- Initial Version
    !
    !> @param[in] td_file   file structure
@@ -735,9 +714,9 @@
          &                                il_len, &
          &                                il_attid )
-         CALL iom_cdf__check(il_status,"IOM CDF READ ATT: ")
+         CALL iom_cdf__check(il_status)
 
          !! get attribute value
-         CALL logger_debug( " IOM CDF READ ATT: get attribute "//&
-            &            TRIM(cl_name)//" in file "//TRIM(td_file%c_name))
+         CALL logger_debug( " IOM CDF READ ATT: get attribute "//TRIM(cl_name)//&
+         &               " in file "//TRIM(td_file%c_name))
 
          SELECT CASE( il_type )
@@ -749,6 +728,6 @@
 
                   CALL logger_error( &
-                  &  " IOM CDF READ ATT: not enough space to put "//&
-                  &  "attribute "//TRIM(cl_name) )
+                  &  " IOM CDF READ ATT: not enough space to put attribute "//&
+                  &  TRIM(cl_name) )
 
                ELSE
@@ -758,5 +737,5 @@
                   &                      cl_name, &
                   &                      cl_value )
-                  CALL iom_cdf__check(il_status,"IOM CDF READ ATT: ")
+                  CALL iom_cdf__check(il_status)
 
                   iom_cdf__read_att_name=att_init(cl_name, cl_value)
@@ -779,5 +758,5 @@
                   &                      cl_name, &
                   &                      bl_value(:))
-                  CALL iom_cdf__check(il_status,"IOM CDF READ ATT: ")   
+                  CALL iom_cdf__check(il_status)   
 
                   iom_cdf__read_att_name=att_init(cl_name, bl_value(:))
@@ -794,6 +773,6 @@
 
                   CALL logger_error( &
-                  &  " IOM CDF READ ATT: not enough space to put "//&
-                  &  "attribute "//TRIM(cl_name) )
+                  &  " IOM CDF READ ATT: not enough space to put attribute "//&
+                  &  TRIM(cl_name) )
 
                ELSE
@@ -803,5 +782,5 @@
                   &                      cl_name, &
                   &                      sl_value(:))
-                  CALL iom_cdf__check(il_status,"IOM CDF READ ATT: ")   
+                  CALL iom_cdf__check(il_status)   
 
                   iom_cdf__read_att_name=att_init(cl_name, sl_value(:))
@@ -818,6 +797,6 @@
 
                   CALL logger_error( &
-                  &  " IOM CDF READ ATT: not enough space to put "//&
-                  &  "attribute "//TRIM(cl_name) )
+                  &  " IOM CDF READ ATT: not enough space to put attribute "//&
+                  &  TRIM(cl_name) )
 
                ELSE
@@ -827,5 +806,5 @@
                   &                      cl_name, &
                   &                      il_value(:))
-                  CALL iom_cdf__check(il_status,"IOM CDF READ ATT: ")   
+                  CALL iom_cdf__check(il_status)   
 
                   iom_cdf__read_att_name=att_init(cl_name, il_value(:))
@@ -841,6 +820,6 @@
 
                   CALL logger_error( &
-                  &  " IOM CDF READ ATT: not enough space to put "//&
-                  &  "attribute "//TRIM(cl_name) )
+                  &  " IOM CDF READ ATT: not enough space to put attribute "//&
+                  &  TRIM(cl_name) )
 
                ELSE
@@ -850,5 +829,5 @@
                   &                      cl_name, &
                   &                      fl_value(:))
-                  CALL iom_cdf__check(il_status,"IOM CDF READ ATT: ")   
+                  CALL iom_cdf__check(il_status)   
 
                   iom_cdf__read_att_name=att_init(cl_name, fl_value(:))
@@ -865,6 +844,6 @@
 
                   CALL logger_error( &
-                  &  " IOM CDF READ ATT: not enough space to put "//&
-                  &  "attribute "//TRIM(cl_name) )
+                  &  " IOM CDF READ ATT: not enough space to put attribute "//&
+                  &  TRIM(cl_name) )
 
                ELSE
@@ -874,5 +853,5 @@
                   &                      cl_name, &
                   &                      dl_value(:))
-                  CALL iom_cdf__check(il_status,"IOM CDF READ ATT: ")   
+                  CALL iom_cdf__check(il_status)   
 
                   iom_cdf__read_att_name=att_init(cl_name, dl_value(:))
@@ -894,5 +873,5 @@
    !
    !> @author J.Paul
-   !> @date November, 2013 - Initial Version
+   !> - November, 2013- Initial Version
    !
    !> @param[in] td_file   file structure
@@ -923,5 +902,5 @@
          ! get attribute name
          il_status=NF90_INQ_ATTNAME(td_file%i_id, id_varid, id_attid, cl_name)
-         CALL iom_cdf__check(il_status,"IOM CDF READ ATT: ")
+         CALL iom_cdf__check(il_status)
 
          ! read attribute
@@ -939,5 +918,5 @@
    !
    !> @author J.Paul
-   !> @date November, 2013 - Initial Version
+   !> - November, 2013- Initial Version
    !
    !> @param[in] td_file   file structure
@@ -997,5 +976,5 @@
    !
    !> @author J.Paul
-   !> @date November, 2013 - Initial Version
+   !> - November, 2013- Initial Version
    !
    !> @param[in] td_file   file structure
@@ -1064,5 +1043,5 @@
    !
    !> @author J.Paul
-   !> @date November, 2013 - Initial Version
+   !> - November, 2013- Initial Version
    !
    !> @param[inout] td_file   file structure
@@ -1106,5 +1085,5 @@
    !
    !> @author J.Paul
-   !> @date November, 2013 - Initial Version
+   !> - November, 2013- Initial Version
    !
    !> @param[inout] td_file   file structure
@@ -1169,5 +1148,5 @@
    !
    !> @author J.Paul
-   !> @date November, 2013 - Initial Version
+   !> - November, 2013- Initial Version
    !
    !> @param[inout] td_file   file structure
@@ -1220,5 +1199,5 @@
    !
    !> @author J.Paul
-   !> @date November, 2013 - Initial Version
+   !> - November, 2013- Initial Version
    !> @date September, 2014
    !> - force to use FillValue=1.e20 if no FillValue for coordinate variable.
@@ -1261,5 +1240,5 @@
 
          ! inquire variable
-         CALL logger_debug( &
+         CALL logger_trace( &
          &  " IOM CDF READ VAR META: inquire variable "//&
          &  TRIM(fct_str(id_varid))//&
@@ -1274,8 +1253,7 @@
          &                                il_dimid(:),&
          &                                il_natt )
-         CALL iom_cdf__check(il_status,"IOM CDF READ VAR META: ")
+         CALL iom_cdf__check(il_status)
          !!! fill variable dimension structure
          tl_dim(:)=iom_cdf__read_var_dim( td_file, il_ndim, il_dimid(:) )
-
          IF( il_natt /= 0 )THEN
             ALLOCATE( tl_att(il_natt) )
@@ -1298,10 +1276,10 @@
                ELSE
                   ! create attribute _FillValue
-                  SELECT CASE(TRIM(fct_lower(cl_name)))
+                  SELECT CASE(TRIM(cl_name))
                      CASE DEFAULT
                         CALL logger_info("IOM CDF READ VAR META: assume _FillValue is equal to "//&
                         &                "zero for variable "//TRIM(cl_name) )
                         tl_fill=att_init('_FillValue',0.)
-                     CASE('nav_lon','nav_lat', 'nav_lev', &
+                     CASE('nav_lon','nav_lat', &
                         &  'glamt','glamu','glamv','glamf', &
                         &  'gphit','gphiu','gphiv','gphif')
@@ -1333,5 +1311,5 @@
             ALLOCATE(tl_att(il_natt+1) )
             ! create attribute _FillValue
-            SELECT CASE(TRIM(fct_lower(cl_name)))
+            SELECT CASE(TRIM(cl_name))
                CASE DEFAULT
                   CALL logger_info("IOM CDF READ VAR META: assume _FillValue is equal to "//&
@@ -1375,8 +1353,6 @@
    !
    !> @author J.Paul
-   !> @date November, 2013 - Initial Version
-   !> @date July, 2015 
-   !> - Bug fix: use order to disorder table (see dim_init)
-   !>
+   !> - November, 2013- Initial Version
+   !
    !> @param[in] td_file   file structure
    !> @param[in] id_ndim   number of dimension
@@ -1395,5 +1371,5 @@
 
       ! local variable
-      INTEGER(i4), DIMENSION(ip_maxdim) :: il_xyzt2
+      INTEGER(i4), DIMENSION(ip_maxdim) :: il_2xyzt
 
       TYPE(TDIM) , DIMENSION(ip_maxdim) :: tl_dim
@@ -1419,17 +1395,17 @@
 
          DO ji = 1, id_ndim
-            CALL logger_debug( " IOM CDF READ VAR DIM: get variable "//&
-               &  "dimension "//TRIM(fct_str(ji)) )
-
-            il_xyzt2(ji)=td_file%t_dim(id_dimid(ji))%i_xyzt2
+            CALL logger_trace( " IOM CDF READ VAR DIM: get variable dimension "//&
+            &               TRIM(fct_str(ji)) )
+
+            il_2xyzt(ji)=td_file%t_dim(id_dimid(ji))%i_2xyzt
 
             ! read dimension information
-            tl_dim(ji) = dim_init( td_file%t_dim(il_xyzt2(ji))%c_name, &
-            &                      td_file%t_dim(il_xyzt2(ji))%i_len )
+            tl_dim(ji) = dim_init( td_file%t_dim(il_2xyzt(ji))%c_name, &
+            &                      td_file%t_dim(il_2xyzt(ji))%i_len )
          ENDDO
 
          ! reorder dimension to ('x','y','z','t')
          CALL dim_reorder(tl_dim(:))
- 
+      
          iom_cdf__read_var_dim(:)=dim_copy(tl_dim(:))
 
@@ -1450,5 +1426,5 @@
    !
    !> @author J.Paul
-   !> @date November, 2013 - Initial Version
+   !> - November, 2013- Initial Version
    !
    !> @param[in] td_file   file structure
@@ -1499,7 +1475,5 @@
    !
    !> @author J.Paul
-   !> @date November, 2013 - Initial Version
-   !> @date June, 2015 
-   !> - use scale factor and offset, as soon as read variable value
+   !> - November, 2013- Initial Version
    !
    !> @param[in] td_file   file structure
@@ -1508,4 +1482,7 @@
    !> @param[in] id_count  number of indices selected along each dimension
    !> @return variable structure completed 
+   !
+   !> @todo
+   !> - warning do not change fill value when use scale factor..
    !-------------------------------------------------------------------
    SUBROUTINE iom_cdf__read_var_value(td_file, td_var, &
@@ -1519,13 +1496,12 @@
 
       ! local variable
-      INTEGER(i4)                                    :: il_status
-      INTEGER(i4)                                    :: il_tmp1
-      INTEGER(i4)                                    :: il_tmp2
-      INTEGER(i4)                                    :: il_varid
-      INTEGER(i4), DIMENSION(ip_maxdim)              :: il_start
-      INTEGER(i4), DIMENSION(ip_maxdim)              :: il_count
-      INTEGER(i4), DIMENSION(ip_maxdim)              :: il_start_ord
-      INTEGER(i4), DIMENSION(ip_maxdim)              :: il_count_ord
-
+      INTEGER(i4)                       :: il_status
+      INTEGER(i4)                       :: il_tmp1
+      INTEGER(i4)                       :: il_tmp2
+      INTEGER(i4)                       :: il_varid
+      INTEGER(i4), DIMENSION(ip_maxdim) :: il_start
+      INTEGER(i4), DIMENSION(ip_maxdim) :: il_count
+      INTEGER(i4), DIMENSION(ip_maxdim) :: il_start_ord
+      INTEGER(i4), DIMENSION(ip_maxdim) :: il_count_ord
       REAL(dp)   , DIMENSION(:,:,:,:)  , ALLOCATABLE :: dl_value
       REAL(dp)   , DIMENSION(:,:,:,:)  , ALLOCATABLE :: dl_tmp
@@ -1542,6 +1518,6 @@
          IF( (       PRESENT(id_start)  .AND. (.NOT. PRESENT(id_count))) .OR. &
              ((.NOT. PRESENT(id_start)) .AND.        PRESENT(id_count) ) )THEN
-            CALL logger_warn( "IOM CDF READ VAR VALUE: id_start and id_count"//&
-               & " should be both specify")
+            CALL logger_warn( &
+            &  "IOM CDF READ VAR VALUE: id_start and id_count should be both specify")
          ENDIF
          IF( PRESENT(id_start).AND.PRESENT(id_count) )THEN
@@ -1549,7 +1525,7 @@
             IF( SIZE(id_start(:)) /= ip_maxdim .OR. &
             &   SIZE(id_count(:)) /= ip_maxdim )THEN
-               CALL logger_error("IOM CDF READ VAR: dimension of array start"//&
-                  &  " or count are invalid to read variable "//&
-                  &  TRIM(td_var%c_name)//" in file "//TRIM(td_file%c_name) )
+               CALL logger_error("IOM CDF READ VAR: dimension of array start or count "//&
+               &      " are invalid to read variable "//TRIM(td_var%c_name)//&
+               &      " in file "//TRIM(td_file%c_name) )
             ENDIF
 
@@ -1588,4 +1564,7 @@
             &    td_var%t_dim( 4 )%i_len &
             &                                            /)) )THEN
+
+            CALL logger_error( "IOM CDF READ VAR VALUE: start + count exceed "//&
+            &  "variable dimension for "//TRIM(td_var%c_name) )
 
             DO ji = 1, ip_maxdim
@@ -1596,10 +1575,8 @@
                &  TRIM(fct_str(il_tmp2)))
             ENDDO
-            CALL logger_error( "IOM CDF READ VAR VALUE: start + count exceed "//&
-            &  "variable dimension for "//TRIM(td_var%c_name) )
 
          ELSE
 
-            ! Allocate space to hold variable value (disorder)
+            ! Allocate space to hold variable value (unorder)
             ALLOCATE(dl_value( il_count(1), &
                &               il_count(2), &
@@ -1624,5 +1601,5 @@
             &                                       start = il_start(:),&
             &                                       count = il_count(:) )
-            CALL iom_cdf__check(il_status,"IOM CDF READ VAR VALUE: ")
+            CALL iom_cdf__check(il_status)
 
             ! Allocate space to hold variable value in structure
@@ -1686,11 +1663,4 @@
                CALL var_chg_FillValue(td_var)
             ENDIF
-
-            ! use scale factor and offset
-            WHERE( td_var%d_value(:,:,:,:) /= td_var%d_fill )
-               td_var%d_value(:,:,:,:) = &
-               &  td_var%d_value(:,:,:,:)*td_var%d_scf + td_var%d_ofs
-            END WHERE
-
          ENDIF
       ELSE
@@ -1703,25 +1673,17 @@
    !-------------------------------------------------------------------
    !> @brief This subroutine write file structure in an opened netcdf file.
-   !>
-   !> @details
-   !> optionally, you could specify dimension order (default 'xyzt')
-   !>
-   !> @author J.Paul
-   !> @date November, 2013 - Initial Version
-   !> @date July, 2015 
-   !> - add dimension order option 
+   !
+   !> @author J.Paul
+   !> - November, 2013- Initial Version
    !
    !> @param[inout] td_file   file structure
    !-------------------------------------------------------------------
-   SUBROUTINE iom_cdf_write_file(td_file, cd_dimorder)
-      IMPLICIT NONE
-      ! Argument      
-      TYPE(TFILE)     , INTENT(INOUT) :: td_file
-      CHARACTER(LEN=*), INTENT(IN   ), OPTIONAL :: cd_dimorder
+   SUBROUTINE iom_cdf_write_file(td_file)
+      IMPLICIT NONE
+      ! Argument      
+      TYPE(TFILE), INTENT(INOUT) :: td_file
 
       ! local variable
       INTEGER(i4), DIMENSION(:), ALLOCATABLE :: il_value
-
-      CHARACTER(LEN=lc)                      :: cl_dimorder
 
       TYPE(TVAR)                             :: tl_var
@@ -1732,9 +1694,5 @@
       INTEGER(i4) :: ji
       INTEGER(i4) :: jj
-      INTEGER(i4) :: jvar
-      !----------------------------------------------------------------
-
-      cl_dimorder='xyzt'
-      IF( PRESENT(cd_dimorder) ) cl_dimorder=TRIM(cd_dimorder)
+      !----------------------------------------------------------------
 
       ! check if file opened
@@ -1768,13 +1726,4 @@
             ENDIF
 
-            ! change dimension order
-            IF( TRIM(cl_dimorder) /= 'xyzt' )THEN
-               CALL dim_reorder(td_file%t_dim(:),TRIM(cl_dimorder))
-               DO jvar=1,td_file%i_nvar
-                  CALL logger_debug("VAR REORDER: "//TRIM(td_file%t_var(jvar)%c_name))
-                  CALL var_reorder(td_file%t_var(jvar),TRIM(cl_dimorder))
-               ENDDO
-            ENDIF
-
             ! write dimension in file
             DO ji = 1, ip_maxdim
@@ -1827,5 +1776,5 @@
    !
    !> @author J.Paul
-   !> @date November, 2013 - Initial Version
+   !> - November, 2013- Initial Version
    !
    !> @param[inout] td_file   file structure
@@ -1849,5 +1798,5 @@
          ! Enter define mode
          il_status=NF90_REDEF(td_file%i_id)
-         CALL iom_cdf__check(il_status,"IOM CDF WRITE FILE DIM: ")
+         CALL iom_cdf__check(il_status)
 
          td_file%l_def=.TRUE.
@@ -1864,9 +1813,9 @@
             il_status=NF90_DEF_DIM(td_file%i_id, fct_upper(td_dim%c_sname), &
             &                      NF90_UNLIMITED, td_dim%i_id)
-            CALL iom_cdf__check(il_status,"IOM CDF WRITE FILE DIM: ")
+            CALL iom_cdf__check(il_status)
 
          ELSE
             ! write not unlimited dimension
-            CALL logger_debug( &
+            CALL logger_trace( &
             &  "IOM CDF WRITE FILE DIM: write dimension "//TRIM(td_dim%c_name)//&
             &  " in file "//TRIM(td_file%c_name))
@@ -1874,5 +1823,5 @@
             il_status=NF90_DEF_DIM(td_file%i_id, fct_upper(td_dim%c_sname), &
             &                      td_dim%i_len, td_dim%i_id)
-            CALL iom_cdf__check(il_status,"IOM CDF WRITE FILE DIM: ")
+            CALL iom_cdf__check(il_status)
 
          ENDIF
@@ -1885,5 +1834,5 @@
    !
    !> @author J.Paul
-   !> @date November, 2013 - Initial Version
+   !> - November, 2013- Initial Version
    !
    !> @param[inout] td_file   file structure
@@ -1910,5 +1859,5 @@
          ! Enter define mode
          il_status=NF90_REDEF(td_file%i_id)
-         CALL iom_cdf__check(il_status,"IOM CDF WRITE FILE ATT: ")
+         CALL iom_cdf__check(il_status)
 
          td_file%l_def=.TRUE.
@@ -1927,5 +1876,5 @@
             il_status = NF90_PUT_ATT(td_file%i_id, id_varid, &
             &  td_att%c_name, td_att%c_value )
-            CALL iom_cdf__check(il_status,"IOM CDF WRITE FILE ATT: ")
+            CALL iom_cdf__check(il_status)
 
          CASE(NF90_BYTE, NF90_SHORT, NF90_INT, NF90_FLOAT, NF90_DOUBLE)
@@ -1933,5 +1882,5 @@
             il_status = NF90_PUT_ATT(td_file%i_id, id_varid, &
             &  td_att%c_name, td_att%d_value )
-            CALL iom_cdf__check(il_status,"IOM CDF WRITE FILE ATT: ")
+            CALL iom_cdf__check(il_status)
 
       END SELECT
@@ -1942,5 +1891,5 @@
    !
    !> @author J.Paul
-   !> @date November, 2013 - Initial Version
+   !> - November, 2013- Initial Version
    !
    !> @param[inout] td_file   file structure
@@ -1968,10 +1917,10 @@
          ! Enter define mode
          il_status=NF90_REDEF(td_file%i_id)
-         CALL iom_cdf__check(il_status,"IOM CDF WRITE VAR: ")
+         CALL iom_cdf__check(il_status)
 
          td_file%l_def=.TRUE.
 
       ENDIF
- 
+      
       ! check if file and variable dimension conform
       IF( file_check_var_dim(td_file, td_var) )THEN
@@ -1989,15 +1938,10 @@
             ENDIF
          ENDDO
-         ! ugly patch until NEMO do not force to use 0. as FillValue 
          IF( ll_chg )THEN
             ! not a dimension variable
             ! change FillValue
-            SELECT CASE( TRIM(fct_lower(td_var%c_name)) )
-               CASE DEFAULT
-                  CALL var_chg_FillValue(td_var,0._dp)
-               CASE('nav_lon','nav_lat', &
-                  & 'glamt','glamu','glamv','glamf', &
-                  & 'gphit','gphiu','gphiv','gphif')
-            END SELECT
+
+            ! ugly patch until NEMO do not force to use 0. as FillValue 
+            CALL var_chg_FillValue(td_var,0._dp)
          ENDIF
 
@@ -2013,5 +1957,5 @@
             ! Leave define mode
             il_status=NF90_ENDDEF(td_file%i_id)
-            CALL iom_cdf__check(il_status,"IOM CDF WRITE VAR: ")
+            CALL iom_cdf__check(il_status)
 
             td_file%l_def=.FALSE.
@@ -2031,5 +1975,5 @@
    !
    !> @author J.Paul
-   !> @date November, 2013 - Initial Version
+   !> - November, 2013- Initial Version
    !
    !> @param[in] td_file   file structure
@@ -2058,17 +2002,9 @@
       tl_var=var_copy(td_var)
 
-      ! forced to use float type
-      IF( tl_var%d_unf /= 1. .AND. tl_var%i_type==NF90_SHORT )THEN
-         tl_var%i_type=NF90_FLOAT
-      ENDIF
-
       IF( ALL( .NOT. tl_var%t_dim(:)%l_use ) )THEN
-         CALL logger_debug( &
-         &  "IOM CDF WRITE VAR DEF scalar: define variable "//&
-         &  TRIM(tl_var%c_name)//" in file "//TRIM(td_file%c_name))
          ! scalar value
          il_status = NF90_DEF_VAR(td_file%i_id, TRIM(tl_var%c_name), &
          &                        tl_var%i_type, varid=iom_cdf__write_var_def) 
-         CALL iom_cdf__check(il_status,"IOM CDF WRITE VAR DEF: ")
+         CALL iom_cdf__check(il_status)
       ELSE
 
@@ -2084,17 +2020,16 @@
          ENDDO
 
-         CALL logger_debug( &
+         CALL logger_trace( &
          &  "IOM CDF WRITE VAR DEF: define dimension to be used for variable "//&
          &  TRIM(tl_var%c_name)//" in file "//TRIM(td_file%c_name))
 
          DO ji=1,jj
-            CALL logger_debug("IOM CDF WRITE VAR DEF: dimid "//TRIM(fct_str(il_dimid(ji))) )
+            CALL logger_trace("IOM CDF WRITE VAR DEF: dimid "//TRIM(fct_str(il_dimid(ji))) )
          ENDDO
-
          il_status = NF90_DEF_VAR(td_file%i_id, TRIM(tl_var%c_name),     &
          &                        tl_var%i_type,                         &
          &                        il_dimid(1:jj),                        &
          &                        varid=iom_cdf__write_var_def           )
-         CALL iom_cdf__check(il_status,"IOM CDF WRITE VAR DEF: ")
+         CALL iom_cdf__check(il_status)
       ENDIF
 
@@ -2108,13 +2043,8 @@
 
       DO ji = 1, tl_var%i_natt
-         CALL logger_debug( &
+         CALL logger_trace( &
          &  " IOM CDF WRITE VAR DEF: put attribute "//TRIM(tl_var%t_att(ji)%c_name)//&
          &  " for variable "//TRIM(tl_var%c_name)//&
          &  " in file "//TRIM(td_file%c_name) )
-
-         ! forced FillValue to have same type than variable
-         IF( TRIM(tl_var%t_att(ji)%c_name) == '_FillValue' )THEN
-            tl_var%t_att(ji)%i_type=tl_var%i_type
-         ENDIF
 
          IF( tl_var%t_att(ji)%i_type == NF90_CHAR )THEN
@@ -2123,5 +2053,5 @@
                &                        TRIM(tl_var%t_att(ji)%c_name),        &
                &                        TRIM(tl_var%t_att(ji)%c_value)        )
-               CALL iom_cdf__check(il_status,"IOM CDF WRITE VAR DEF: ")
+               CALL iom_cdf__check(il_status)
             ENDIF
          ELSE
@@ -2152,6 +2082,6 @@
                   &                        TRIM(tl_var%t_att(ji)%c_name),  &
                   &                        REAL(tl_var%t_att(ji)%d_value(:),dp))
-            END SELECT
-            CALL iom_cdf__check(il_status,"IOM CDF WRITE VAR DEF: ")
+               END SELECT
+            CALL iom_cdf__check(il_status)
          ENDIF
       ENDDO
@@ -2167,7 +2097,5 @@
    !
    !> @author J.Paul
-   !> @date November, 2013 - Initial Version
-   !> @date June, 2015
-   !> - reuse scale factor and offset, before writing variable
+   !> - November, 2013- Initial Version
    !
    !> @param[in] td_file   file structure
@@ -2194,11 +2122,5 @@
       &  "IOM CDF WRITE VAR VALUE: get dimension to be used for variable "//&
       &  TRIM(td_var%c_name)//" in file "//TRIM(td_file%c_name))
-   
-      ! use scale factor and offset
-      WHERE( td_var%d_value(:,:,:,:) /= td_var%d_fill )
-         td_var%d_value(:,:,:,:) = &
-         &  (td_var%d_value(:,:,:,:)-td_var%d_ofs)/td_var%d_scf
-      END WHERE
-      
+
       jj=0
       DO ji = 1, ip_maxdim
@@ -2231,5 +2153,5 @@
 
       il_status = NF90_PUT_VAR( td_file%i_id, td_var%i_id, dl_value(:,:,:,:))
-      CALL iom_cdf__check(il_status,"IOM CDF WRITE VAR VALUE: ")
+      CALL iom_cdf__check(il_status)
 
       DEALLOCATE( dl_value )
