Index: LMDZ5/branches/testing/libf/bibio/netcdf95.F90
===================================================================
--- LMDZ5/branches/testing/libf/bibio/netcdf95.F90	(revision 1665)
+++ LMDZ5/branches/testing/libf/bibio/netcdf95.F90	(revision 1669)
@@ -3,38 +3,10 @@
 
   ! Author: Lionel GUEZ
-
-  ! Three criticisms may be made about the Fortran 90 NetCDF interface:
-
-  ! -- NetCDF procedures are usually functions with side effects.
-  ! First, they have "intent(out)" arguments.
-  ! Furthermore, there is obviously data transfer inside the procedures.
-  ! Any data transfer inside a function is considered as a side effect.
-
-  ! -- The caller of a NetCDF procedure usually has to handle the error
-  ! status. NetCDF procedures would be much friendlier if they behaved
-  ! like the Fortran input/output statements. That is, the error status
-  ! should be an optional output argument.
-  ! If the caller does not request the error status and there is an
-  ! error then the NetCDF procedure should produce an error message
-  ! and stop the program.
-
-  ! -- Some procedures use array arguments with assumed size.
-  ! It would be better to use the pointer attribute.
-
-  ! This module produces a NetCDF interface that answers those three
-  ! criticisms for some (not all) procedures.
-
-  ! "nf95_get_att" is more secure than "nf90_get_att" because it
-  ! checks that the "values" argument is long enough and removes the
-  ! null terminator, if any.
-
-  ! This module replaces some of the official NetCDF procedures.
-  ! This module also provides the procedures "handle_err" and "nf95_gw_var".
-
-  ! This module provides only a partial replacement for some generic
-  ! procedures such as "nf90_def_var".
+  ! See:
+  ! http://www.lmd.jussieu.fr/~lglmd/NetCDF95
 
   use nf95_def_var_m
   use nf95_put_var_m
+  use nf95_get_var_m
   use nf95_gw_var_m
   use nf95_put_att_m
Index: LMDZ5/branches/testing/libf/bibio/nf95_get_att_m.F90
===================================================================
--- LMDZ5/branches/testing/libf/bibio/nf95_get_att_m.F90	(revision 1665)
+++ LMDZ5/branches/testing/libf/bibio/nf95_get_att_m.F90	(revision 1669)
@@ -1,9 +1,16 @@
 ! $Id$
 module nf95_get_att_m
+
+  use handle_err_m, only: handle_err
+  use netcdf, only: nf90_get_att, nf90_noerr
+  use simple, only: nf95_inquire_attribute
 
   implicit none
 
   interface nf95_get_att
-     module procedure nf95_get_att_text
+     module procedure nf95_get_att_text, nf95_get_att_one_FourByteInt
+
+     ! The difference between the specific procedures is the type of
+     ! argument "values".
   end interface
 
@@ -15,7 +22,4 @@
   subroutine nf95_get_att_text(ncid, varid, name, values, ncerr)
 
-    use netcdf, only: nf90_get_att, nf90_inquire_attribute, nf90_noerr
-    use handle_err_m, only: handle_err
-
     integer,                          intent( in) :: ncid, varid
     character(len = *),               intent( in) :: name
@@ -23,5 +27,5 @@
     integer, intent(out), optional:: ncerr
 
-    ! Variable local to the procedure:
+    ! Variables local to the procedure:
     integer ncerr_not_opt
     integer att_len
@@ -30,15 +34,16 @@
 
     ! Check that the length of "values" is large enough:
-    ncerr_not_opt = nf90_inquire_attribute(ncid, varid, name, len=att_len)
-    call handle_err("nf95_get_att_text nf90_inquire_attribute " &
-         // trim(name), ncerr_not_opt, ncid, varid)
-    if (len(values) < att_len) then
-       print *, "nf95_get_att_text"
-       print *, "varid = ", varid
-       print *, "attribute name: ", name
-       print *, 'length of "values" is not large enough'
-       print *, "len(values) = ", len(values)
-       print *, "number of characters in attribute: ", att_len
-       stop 1
+    call nf95_inquire_attribute(ncid, varid, name, nclen=att_len, &
+         ncerr=ncerr_not_opt)
+    if (ncerr_not_opt == nf90_noerr) then
+       if (len(values) < att_len) then
+          print *, "nf95_get_att_text"
+          print *, "varid = ", varid
+          print *, "attribute name: ", name
+          print *, 'length of "values" is not large enough'
+          print *, "len(values) = ", len(values)
+          print *, "number of characters in attribute: ", att_len
+          stop 1
+       end if
     end if
 
@@ -48,5 +53,6 @@
        ncerr = ncerr_not_opt
     else
-       call handle_err("nf95_get_att_text", ncerr_not_opt, ncid, varid)
+       call handle_err("nf95_get_att_text " // trim(name), ncerr_not_opt, &
+            ncid, varid)
     end if
 
@@ -58,3 +64,42 @@
   end subroutine nf95_get_att_text
 
+  !***********************
+
+  subroutine nf95_get_att_one_FourByteInt(ncid, varid, name, values, ncerr)
+
+    integer,                                    intent( in) :: ncid, varid
+    character(len = *),                         intent( in) :: name
+    integer ,               intent(out) :: values
+    integer, intent(out), optional:: ncerr
+
+    ! Variables local to the procedure:
+    integer ncerr_not_opt
+    integer att_len
+
+    !-------------------
+
+    ! Check that the attribute contains a single value:
+    call nf95_inquire_attribute(ncid, varid, name, nclen=att_len, &
+         ncerr=ncerr_not_opt)
+    if (ncerr_not_opt == nf90_noerr) then
+       if (att_len /= 1) then
+          print *, "nf95_get_att_one_FourByteInt"
+          print *, "varid = ", varid
+          print *, "attribute name: ", name
+          print *, 'the attribute does not contain a single value'
+          print *, "number of values in attribute: ", att_len
+          stop 1
+       end if
+    end if
+
+    ncerr_not_opt = nf90_get_att(ncid, varid, name, values)
+    if (present(ncerr)) then
+       ncerr = ncerr_not_opt
+    else
+       call handle_err("nf95_get_att_one_FourByteInt " // trim(name), &
+            ncerr_not_opt, ncid, varid)
+    end if
+
+  end subroutine nf95_get_att_one_FourByteInt
+
 end module nf95_get_att_m
Index: LMDZ5/branches/testing/libf/bibio/nf95_get_var_m.F90
===================================================================
--- LMDZ5/branches/testing/libf/bibio/nf95_get_var_m.F90	(revision 1669)
+++ LMDZ5/branches/testing/libf/bibio/nf95_get_var_m.F90	(revision 1669)
@@ -0,0 +1,391 @@
+module nf95_get_var_m
+
+  use netcdf, only: nf90_get_var
+  use handle_err_m, only: handle_err
+
+  implicit none
+
+  interface nf95_get_var
+     module procedure nf95_get_var_FourByteReal, nf95_get_var_FourByteInt, &
+          nf95_get_var_1D_FourByteReal, nf95_get_var_1D_FourByteInt, &
+          nf95_get_var_2D_FourByteReal, &
+          nf95_get_var_3D_FourByteInt, &
+          nf95_get_var_3D_FourByteReal, &
+          nf95_get_var_4D_FourByteReal, &
+          nf95_get_var_5D_FourByteReal
+  end interface
+
+  private
+  public nf95_get_var
+
+contains
+
+  subroutine nf95_get_var_FourByteReal(ncid, varid, values, start, ncerr)
+
+    integer, intent(in) :: ncid, varid
+    real, intent(out) :: values
+    integer, dimension(:), optional, intent(in) :: start
+    integer, intent(out), optional:: ncerr
+
+    ! Variable local to the procedure:
+    integer ncerr_not_opt
+
+    !-------------------
+
+    ncerr_not_opt = nf90_get_var(ncid, varid, values, start)
+    if (present(ncerr)) then
+       ncerr = ncerr_not_opt
+    else
+       call handle_err("nf95_get_var_FourByteReal", ncerr_not_opt, ncid, &
+            varid)
+    end if
+
+  end subroutine nf95_get_var_FourByteReal
+
+  !***********************
+
+  subroutine nf95_get_var_FourByteInt(ncid, varid, values, start, ncerr)
+
+    integer, intent(in) :: ncid, varid
+    integer, intent(out) :: values
+    integer, dimension(:), optional, intent(in) :: start
+    integer, intent(out), optional:: ncerr
+
+    ! Variable local to the procedure:
+    integer ncerr_not_opt
+
+    !-------------------
+
+    ncerr_not_opt = nf90_get_var(ncid, varid, values, start)
+    if (present(ncerr)) then
+       ncerr = ncerr_not_opt
+    else
+       call handle_err("nf95_get_var_FourByteInt", ncerr_not_opt, ncid, &
+            varid)
+    end if
+
+  end subroutine nf95_get_var_FourByteInt
+
+  !***********************
+
+  subroutine nf95_get_var_1D_FourByteReal(ncid, varid, values, start, &
+       count_nc, stride, map, ncerr)
+
+    integer,                         intent(in) :: ncid, varid
+    real, intent(out) :: values(:)
+    integer, dimension(:), optional, intent(in) :: start, count_nc, stride, map
+    integer, intent(out), optional:: ncerr
+
+    ! Variable local to the procedure:
+    integer ncerr_not_opt
+
+    !-------------------
+
+    ncerr_not_opt = nf90_get_var(ncid, varid, values, start, count_nc, &
+         stride, map)
+    if (present(ncerr)) then
+       ncerr = ncerr_not_opt
+    else
+       call handle_err("nf95_get_var_1D_FourByteReal", ncerr_not_opt, ncid, &
+            varid)
+    end if
+
+  end subroutine nf95_get_var_1D_FourByteReal
+
+  !***********************
+
+  subroutine nf95_get_var_1D_FourByteInt(ncid, varid, values, start, &
+       count_nc, stride, map, ncerr)
+
+    integer,                         intent(in) :: ncid, varid
+    integer, intent(out) :: values(:)
+    integer, dimension(:), optional, intent(in) :: start, count_nc, stride, map
+    integer, intent(out), optional:: ncerr
+
+    ! Variable local to the procedure:
+    integer ncerr_not_opt
+
+    !-------------------
+
+    ncerr_not_opt = nf90_get_var(ncid, varid, values, start, count_nc, &
+         stride, map)
+    if (present(ncerr)) then
+       ncerr = ncerr_not_opt
+    else
+       call handle_err("nf95_get_var_1D_FourByteInt", ncerr_not_opt, ncid, &
+            varid)
+    end if
+
+  end subroutine nf95_get_var_1D_FourByteInt
+
+  !***********************
+
+  subroutine nf95_get_var_1D_EightByteReal(ncid, varid, values, start, &
+       count_nc, stride, map, ncerr)
+
+    use typesizes, only: eightByteReal
+
+    integer,                         intent(in) :: ncid, varid
+    real (kind = EightByteReal),     intent(out) :: values(:)
+    integer, dimension(:), optional, intent(in):: start, count_nc, stride, map
+    integer, intent(out), optional:: ncerr
+
+    ! Variable local to the procedure:
+    integer ncerr_not_opt
+
+    !-------------------
+
+    ncerr_not_opt = nf90_get_var(ncid, varid, values, start, count_nc, &
+         stride, map)
+    if (present(ncerr)) then
+       ncerr = ncerr_not_opt
+    else
+       call handle_err("nf95_get_var_1D_eightByteReal", ncerr_not_opt, ncid, &
+            varid)
+    end if
+
+  end subroutine nf95_get_var_1D_EightByteReal
+
+  !***********************
+
+  subroutine nf95_get_var_2D_FourByteReal(ncid, varid, values, start, &
+       count_nc, stride, map, ncerr)
+
+    integer,                         intent(in) :: ncid, varid
+    real , intent(out) :: values(:, :)
+    integer, dimension(:), optional, intent(in) :: start, count_nc, stride, map
+    integer, intent(out), optional:: ncerr
+
+    ! Variable local to the procedure:
+    integer ncerr_not_opt
+
+    !-------------------
+
+    ncerr_not_opt = nf90_get_var(ncid, varid, values, start, count_nc, &
+         stride, map)
+    if (present(ncerr)) then
+       ncerr = ncerr_not_opt
+    else
+       call handle_err("nf95_get_var_2D_FourByteReal", ncerr_not_opt, ncid, &
+            varid)
+    end if
+
+  end subroutine nf95_get_var_2D_FourByteReal
+
+  !***********************
+
+  subroutine nf95_get_var_2D_EightByteReal(ncid, varid, values, start, &
+       count_nc, stride, map, ncerr)
+
+    use typesizes, only: EightByteReal
+
+    integer,                         intent(in) :: ncid, varid
+    real (kind = EightByteReal), intent(out) :: values(:, :)
+    integer, dimension(:), optional, intent(in) :: start, count_nc, stride, map
+    integer, intent(out), optional:: ncerr
+
+    ! Variable local to the procedure:
+    integer ncerr_not_opt
+
+    !-------------------
+
+    ncerr_not_opt = nf90_get_var(ncid, varid, values, start, count_nc, &
+         stride, map)
+    if (present(ncerr)) then
+       ncerr = ncerr_not_opt
+    else
+       call handle_err("nf95_get_var_2D_EightByteReal", ncerr_not_opt, ncid, &
+            varid)
+    end if
+
+  end subroutine nf95_get_var_2D_EightByteReal
+
+  !***********************
+
+  subroutine nf95_get_var_3D_FourByteInt(ncid, varid, values, start, &
+       count_nc, stride, map, ncerr)
+
+    integer, intent(in):: ncid, varid
+    integer, intent(out):: values(:, :, :)
+    integer, dimension(:), optional, intent(in):: start, count_nc, stride, map
+    integer, intent(out), optional:: ncerr
+
+    ! Variable local to the procedure:
+    integer ncerr_not_opt
+
+    !-------------------
+
+    ncerr_not_opt = nf90_get_var(ncid, varid, values, start, count_nc, &
+         stride, map)
+    if (present(ncerr)) then
+       ncerr = ncerr_not_opt
+    else
+       call handle_err("nf95_get_var_3D_FourByteInt", ncerr_not_opt, ncid, &
+            varid)
+    end if
+
+  end subroutine nf95_get_var_3D_FourByteInt
+
+  !***********************
+
+  subroutine nf95_get_var_3D_FourByteReal(ncid, varid, values, start, &
+       count_nc, stride, map, ncerr)
+
+    integer,                         intent(in) :: ncid, varid
+    real , intent(out) :: values(:, :, :)
+    integer, dimension(:), optional, intent(in) :: start, count_nc, stride, map
+    integer, intent(out), optional:: ncerr
+
+    ! Variable local to the procedure:
+    integer ncerr_not_opt
+
+    !-------------------
+
+    ncerr_not_opt = nf90_get_var(ncid, varid, values, start, count_nc, &
+         stride, map)
+    if (present(ncerr)) then
+       ncerr = ncerr_not_opt
+    else
+       call handle_err("nf95_get_var_3D_FourByteReal", ncerr_not_opt, ncid, &
+            varid)
+    end if
+
+  end subroutine nf95_get_var_3D_FourByteReal
+
+  !***********************
+
+  subroutine nf95_get_var_3D_EightByteReal(ncid, varid, values, start, &
+       count_nc, stride, map, ncerr)
+
+    use typesizes, only: eightByteReal
+
+    integer,                         intent(in) :: ncid, varid
+    real (kind = EightByteReal),     intent(out) :: values(:, :, :)
+    integer, dimension(:), optional, intent(in) :: start, count_nc, stride, map
+    integer, intent(out), optional:: ncerr
+
+    ! Variable local to the procedure:
+    integer ncerr_not_opt
+
+    !-------------------
+
+    ncerr_not_opt = nf90_get_var(ncid, varid, values, start, count_nc, &
+         stride, map)
+    if (present(ncerr)) then
+       ncerr = ncerr_not_opt
+    else
+       call handle_err("nf95_get_var_3D_eightByteReal", ncerr_not_opt, ncid, &
+            varid)
+    end if
+
+  end subroutine nf95_get_var_3D_EightByteReal
+
+  !***********************
+
+  subroutine nf95_get_var_4D_FourByteReal(ncid, varid, values, start, &
+       count_nc, stride, map, ncerr)
+
+    integer,                         intent(in) :: ncid, varid
+    real , intent(out) :: values(:, :, :, :)
+    integer, dimension(:), optional, intent(in) :: start, count_nc, stride, map
+    integer, intent(out), optional:: ncerr
+
+    ! Variable local to the procedure:
+    integer ncerr_not_opt
+
+    !-------------------
+
+    ncerr_not_opt = nf90_get_var(ncid, varid, values, start, count_nc, &
+         stride, map)
+    if (present(ncerr)) then
+       ncerr = ncerr_not_opt
+    else
+       call handle_err("nf95_get_var_4D_FourByteReal", ncerr_not_opt, ncid, &
+            varid)
+    end if
+
+  end subroutine nf95_get_var_4D_FourByteReal
+
+  !***********************
+
+  subroutine nf95_get_var_4D_EightByteReal(ncid, varid, values, start, &
+       count_nc, stride, map, ncerr)
+
+    use typesizes, only: EightByteReal
+
+    integer, intent(in):: ncid, varid
+    real(kind = EightByteReal), intent(out):: values(:, :, :, :)
+    integer, dimension(:), optional, intent(in):: start, count_nc, stride, map
+    integer, intent(out), optional:: ncerr
+
+    ! Variable local to the procedure:
+    integer ncerr_not_opt
+
+    !-------------------
+
+    ncerr_not_opt = nf90_get_var(ncid, varid, values, start, count_nc, &
+         stride, map)
+    if (present(ncerr)) then
+       ncerr = ncerr_not_opt
+    else
+       call handle_err("nf95_get_var_4D_EightByteReal", ncerr_not_opt, ncid, &
+            varid)
+    end if
+
+  end subroutine nf95_get_var_4D_EightByteReal
+
+  !***********************
+
+  subroutine nf95_get_var_5D_FourByteReal(ncid, varid, values, start, &
+       count_nc, stride, map, ncerr)
+
+    integer, intent(in):: ncid, varid
+    real, intent(out):: values(:, :, :, :, :)
+    integer, dimension(:), optional, intent(in):: start, count_nc, stride, map
+    integer, intent(out), optional:: ncerr
+
+    ! Variable local to the procedure:
+    integer ncerr_not_opt
+
+    !-------------------
+
+    ncerr_not_opt = nf90_get_var(ncid, varid, values, start, count_nc, &
+         stride, map)
+    if (present(ncerr)) then
+       ncerr = ncerr_not_opt
+    else
+       call handle_err("nf95_get_var_5D_FourByteReal", ncerr_not_opt, ncid, &
+            varid)
+    end if
+
+  end subroutine nf95_get_var_5D_FourByteReal
+
+  !***********************
+
+  subroutine nf95_get_var_5D_EightByteReal(ncid, varid, values, start, &
+       count_nc, stride, map, ncerr)
+
+    use typesizes, only: EightByteReal
+
+    integer, intent(in):: ncid, varid
+    real(kind = EightByteReal), intent(out):: values(:, :, :, :, :)
+    integer, dimension(:), optional, intent(in):: start, count_nc, stride, map
+    integer, intent(out), optional:: ncerr
+
+    ! Variable local to the procedure:
+    integer ncerr_not_opt
+
+    !-------------------
+
+    ncerr_not_opt = nf90_get_var(ncid, varid, values, start, count_nc, &
+         stride, map)
+    if (present(ncerr)) then
+       ncerr = ncerr_not_opt
+    else
+       call handle_err("nf95_get_var_5D_EightByteReal", ncerr_not_opt, ncid, &
+            varid)
+    end if
+
+  end subroutine nf95_get_var_5D_EightByteReal
+
+end module nf95_get_var_m
Index: LMDZ5/branches/testing/libf/bibio/nf95_gw_var_m.F90
===================================================================
--- LMDZ5/branches/testing/libf/bibio/nf95_gw_var_m.F90	(revision 1665)
+++ LMDZ5/branches/testing/libf/bibio/nf95_gw_var_m.F90	(revision 1669)
@@ -1,4 +1,7 @@
 ! $Id$
 module nf95_gw_var_m
+
+  use nf95_get_var_m, only: NF95_GET_VAR
+  use simple, only: nf95_inquire_variable, nf95_inquire_dimension
 
   implicit none
@@ -8,14 +11,14 @@
      ! These procedures read a whole NetCDF variable (coordinate or
      ! primary) into an array.
-     ! The difference between the procedures is the rank of the array
-     ! and the type of Fortran values.
+     ! The difference between the procedures is the rank and type of
+     ! argument "values".
      ! The procedures do not check the type of the NetCDF variable.
 
-!!$     module procedure nf95_gw_var_real_1d, nf95_gw_var_real_2d, &
-!!$          nf95_gw_var_real_3d, nf95_gw_var_real_4d, nf95_gw_var_dble_1d, &
-!!$          nf95_gw_var_dble_3d, nf95_gw_var_int_1d, nf95_gw_var_int_3d
+     ! Not including double precision procedures in the generic
+     ! interface because we use a compilation option that changes default
+     ! real precision.
      module procedure nf95_gw_var_real_1d, nf95_gw_var_real_2d, &
-          nf95_gw_var_real_3d, nf95_gw_var_real_4d, nf95_gw_var_int_1d, &
-          nf95_gw_var_int_3d
+          nf95_gw_var_real_3d, nf95_gw_var_real_4d, nf95_gw_var_real_5d, &
+          nf95_gw_var_int_1d, nf95_gw_var_int_3d
   end interface
 
@@ -29,8 +32,4 @@
     ! Real type, the array has rank 1.
 
-    use netcdf, only: NF90_GET_VAR
-    use simple, only: nf95_inquire_variable, nf95_inquire_dimension
-    use handle_err_m, only: handle_err
-
     integer, intent(in):: ncid
     integer, intent(in):: varid
@@ -38,6 +37,6 @@
 
     ! Variables local to the procedure:
-    integer ierr, len
-    integer, pointer :: dimids(:)
+    integer nclen
+    integer, pointer:: dimids(:)
 
     !---------------------
@@ -46,16 +45,15 @@
 
     if (size(dimids) /= 1) then
-       print *, "nf95_gw_var_real_1d: NetCDF variable is not of rank 1"
-       stop 1
-    end if
-
-    call nf95_inquire_dimension(ncid, dimids(1), len=len)
-    deallocate(dimids) ! pointer
-
-    allocate(values(len))
-    if (len /= 0) then
-       ierr = NF90_GET_VAR(ncid, varid, values)
-       call handle_err("NF90_GET_VAR", ierr, ncid, varid)
-    end if
+       print *, "nf95_gw_var_real_1d:"
+       print *, "varid = ", varid
+       print *, "rank of NetCDF variable is ", size(dimids), ", not 1"
+       stop 1
+    end if
+
+    call nf95_inquire_dimension(ncid, dimids(1), nclen=nclen)
+    deallocate(dimids) ! pointer
+
+    allocate(values(nclen))
+    if (nclen /= 0) call NF95_GET_VAR(ncid, varid, values)
 
   end subroutine nf95_gw_var_real_1d
@@ -67,8 +65,4 @@
     ! Real type, the array has rank 2.
 
-    use netcdf, only: NF90_GET_VAR
-    use simple, only: nf95_inquire_variable, nf95_inquire_dimension
-    use handle_err_m, only: handle_err
-
     integer, intent(in):: ncid
     integer, intent(in):: varid
@@ -76,6 +70,6 @@
 
     ! Variables local to the procedure:
-    integer ierr, len1, len2
-    integer, pointer :: dimids(:)
+    integer nclen1, nclen2
+    integer, pointer:: dimids(:)
 
     !---------------------
@@ -84,17 +78,16 @@
 
     if (size(dimids) /= 2) then
-       print *, "nf95_gw_var_real_2d: NetCDF variable is not of rank 2"
-       stop 1
-    end if
-
-    call nf95_inquire_dimension(ncid, dimids(1), len=len1)
-    call nf95_inquire_dimension(ncid, dimids(2), len=len2)
-    deallocate(dimids) ! pointer
-
-    allocate(values(len1, len2))
-    if (len1 /= 0 .and. len2 /= 0) then
-       ierr = NF90_GET_VAR(ncid, varid, values)
-       call handle_err("NF90_GET_VAR", ierr, ncid, varid)
-    end if
+       print *, "nf95_gw_var_real_2d:"
+       print *, "varid = ", varid
+       print *, "rank of NetCDF variable is ", size(dimids), ", not 2"
+       stop 1
+    end if
+
+    call nf95_inquire_dimension(ncid, dimids(1), nclen=nclen1)
+    call nf95_inquire_dimension(ncid, dimids(2), nclen=nclen2)
+    deallocate(dimids) ! pointer
+
+    allocate(values(nclen1, nclen2))
+    if (nclen1 /= 0 .and. nclen2 /= 0) call NF95_GET_VAR(ncid, varid, values)
 
   end subroutine nf95_gw_var_real_2d
@@ -106,8 +99,4 @@
     ! Real type, the array has rank 3.
 
-    use netcdf, only: NF90_GET_VAR
-    use simple, only: nf95_inquire_variable, nf95_inquire_dimension
-    use handle_err_m, only: handle_err
-
     integer, intent(in):: ncid
     integer, intent(in):: varid
@@ -115,6 +104,6 @@
 
     ! Variables local to the procedure:
-    integer ierr, len1, len2, len3
-    integer, pointer :: dimids(:)
+    integer nclen1, nclen2, nclen3
+    integer, pointer:: dimids(:)
 
     !---------------------
@@ -123,18 +112,17 @@
 
     if (size(dimids) /= 3) then
-       print *, "nf95_gw_var_real_3d: NetCDF variable is not of rank 3"
-       stop 1
-    end if
-
-    call nf95_inquire_dimension(ncid, dimids(1), len=len1)
-    call nf95_inquire_dimension(ncid, dimids(2), len=len2)
-    call nf95_inquire_dimension(ncid, dimids(3), len=len3)
-    deallocate(dimids) ! pointer
-
-    allocate(values(len1, len2, len3))
-    if (len1 * len2 * len3 /= 0) then
-       ierr = NF90_GET_VAR(ncid, varid, values)
-       call handle_err("NF90_GET_VAR", ierr, ncid, varid)
-    end if
+       print *, "nf95_gw_var_real_3d:"
+       print *, "varid = ", varid
+       print *, "rank of NetCDF variable is ", size(dimids), ", not 3"
+       stop 1
+    end if
+
+    call nf95_inquire_dimension(ncid, dimids(1), nclen=nclen1)
+    call nf95_inquire_dimension(ncid, dimids(2), nclen=nclen2)
+    call nf95_inquire_dimension(ncid, dimids(3), nclen=nclen3)
+    deallocate(dimids) ! pointer
+
+    allocate(values(nclen1, nclen2, nclen3))
+    if (nclen1 * nclen2 * nclen3 /= 0) call NF95_GET_VAR(ncid, varid, values)
 
   end subroutine nf95_gw_var_real_3d
@@ -146,8 +134,4 @@
     ! Real type, the array has rank 4.
 
-    use netcdf, only: NF90_GET_VAR
-    use simple, only: nf95_inquire_variable, nf95_inquire_dimension
-    use handle_err_m, only: handle_err
-
     integer, intent(in):: ncid
     integer, intent(in):: varid
@@ -155,6 +139,6 @@
 
     ! Variables local to the procedure:
-    integer ierr, len_dim(4), i
-    integer, pointer :: dimids(:)
+    integer len_dim(4), i
+    integer, pointer:: dimids(:)
 
     !---------------------
@@ -163,18 +147,17 @@
 
     if (size(dimids) /= 4) then
-       print *, "nf95_gw_var_real_4d: NetCDF variable is not of rank 4"
+       print *, "nf95_gw_var_real_4d:"
+       print *, "varid = ", varid
+       print *, "rank of NetCDF variable is ", size(dimids), ", not 4"
        stop 1
     end if
 
     do i = 1, 4
-       call nf95_inquire_dimension(ncid, dimids(i), len=len_dim(i))
+       call nf95_inquire_dimension(ncid, dimids(i), nclen=len_dim(i))
     end do
     deallocate(dimids) ! pointer
 
     allocate(values(len_dim(1), len_dim(2), len_dim(3), len_dim(4)))
-    if (all(len_dim /= 0)) then
-       ierr = NF90_GET_VAR(ncid, varid, values)
-       call handle_err("NF90_GET_VAR", ierr, ncid, varid)
-    end if
+    if (all(len_dim /= 0)) call NF95_GET_VAR(ncid, varid, values)
 
   end subroutine nf95_gw_var_real_4d
@@ -182,11 +165,42 @@
   !************************************
 
+  subroutine nf95_gw_var_real_5d(ncid, varid, values)
+
+    ! Real type, the array has rank 5.
+
+    integer, intent(in):: ncid
+    integer, intent(in):: varid
+    real, pointer:: values(:, :, :, :, :)
+
+    ! Variables local to the procedure:
+    integer len_dim(5), i
+    integer, pointer:: dimids(:)
+
+    !---------------------
+
+    call nf95_inquire_variable(ncid, varid, dimids=dimids)
+
+    if (size(dimids) /= 5) then
+       print *, "nf95_gw_var_real_5d:"
+       print *, "varid = ", varid
+       print *, "rank of NetCDF variable is ", size(dimids), ", not 5"
+       stop 1
+    end if
+
+    do i = 1, 5
+       call nf95_inquire_dimension(ncid, dimids(i), nclen=len_dim(i))
+    end do
+    deallocate(dimids) ! pointer
+
+    allocate(values(len_dim(1), len_dim(2), len_dim(3), len_dim(4), len_dim(5)))
+    if (all(len_dim /= 0)) call NF95_GET_VAR(ncid, varid, values)
+
+  end subroutine nf95_gw_var_real_5d
+
+  !************************************
+
 !!$  subroutine nf95_gw_var_dble_1d(ncid, varid, values)
 !!$
 !!$    ! Double precision, the array has rank 1.
-!!$
-!!$    use netcdf, only: NF90_GET_VAR
-!!$    use simple, only: nf95_inquire_variable, nf95_inquire_dimension
-!!$    use handle_err_m, only: handle_err
 !!$
 !!$    integer, intent(in):: ncid
@@ -195,6 +209,6 @@
 !!$
 !!$    ! Variables local to the procedure:
-!!$    integer ierr, len
-!!$    integer, pointer :: dimids(:)
+!!$    integer nclen
+!!$    integer, pointer:: dimids(:)
 !!$
 !!$    !---------------------
@@ -203,16 +217,15 @@
 !!$
 !!$    if (size(dimids) /= 1) then
-!!$       print *, "nf95_gw_var_dble_1d: NetCDF variable is not of rank 1"
-!!$       stop 1
+!!$       print *, "nf95_gw_var_dble_1d:"
+!!$       print *, "varid = ", varid
+!!$       print *, "rank of NetCDF variable is ", size(dimids), ", not 1"
+!!$        stop 1
 !!$    end if
 !!$
-!!$    call nf95_inquire_dimension(ncid, dimids(1), len=len)
+!!$    call nf95_inquire_dimension(ncid, dimids(1), nclen=nclen)
 !!$    deallocate(dimids) ! pointer
 !!$
-!!$    allocate(values(len))
-!!$    if (len /= 0) then
-!!$       ierr = NF90_GET_VAR(ncid, varid, values)
-!!$       call handle_err("NF90_GET_VAR", ierr, ncid, varid)
-!!$    end if
+!!$    allocate(values(nclen))
+!!$    if (nclen /= 0) call NF95_GET_VAR(ncid, varid, values)
 !!$
 !!$  end subroutine nf95_gw_var_dble_1d
@@ -223,8 +236,4 @@
 !!$
 !!$    ! Double precision, the array has rank 3.
-!!$
-!!$    use netcdf, only: NF90_GET_VAR
-!!$    use simple, only: nf95_inquire_variable, nf95_inquire_dimension
-!!$    use handle_err_m, only: handle_err
 !!$
 !!$    integer, intent(in):: ncid
@@ -233,6 +242,6 @@
 !!$
 !!$    ! Variables local to the procedure:
-!!$    integer ierr, len1, len2, len3
-!!$    integer, pointer :: dimids(:)
+!!$    integer nclen1, nclen2, nclen3
+!!$    integer, pointer:: dimids(:)
 !!$
 !!$    !---------------------
@@ -241,21 +250,20 @@
 !!$
 !!$    if (size(dimids) /= 3) then
-!!$       print *, "nf95_gw_var_dble_3d: NetCDF variable is not of rank 3"
+!!$       print *, "nf95_gw_var_dble_3d:"
+!!$       print *, "varid = ", varid
+!!$       print *, "rank of NetCDF variable is ", size(dimids), ", not 3"
 !!$       stop 1
 !!$    end if
 !!$
-!!$    call nf95_inquire_dimension(ncid, dimids(1), len=len1)
-!!$    call nf95_inquire_dimension(ncid, dimids(2), len=len2)
-!!$    call nf95_inquire_dimension(ncid, dimids(3), len=len3)
+!!$    call nf95_inquire_dimension(ncid, dimids(1), nclen=nclen1)
+!!$    call nf95_inquire_dimension(ncid, dimids(2), nclen=nclen2)
+!!$    call nf95_inquire_dimension(ncid, dimids(3), nclen=nclen3)
 !!$    deallocate(dimids) ! pointer
 !!$
-!!$    allocate(values(len1, len2, len3))
-!!$    if (len1 * len2 * len3 /= 0) then
-!!$       ierr = NF90_GET_VAR(ncid, varid, values)
-!!$       call handle_err("NF90_GET_VAR", ierr, ncid, varid)
-!!$    end if
+!!$    allocate(values(nclen1, nclen2, nclen3))
+!!$    if (nclen1 * nclen2 * nclen3 /= 0) call NF95_GET_VAR(ncid, varid, values)
 !!$
 !!$  end subroutine nf95_gw_var_dble_3d
-
+!!$
   !************************************
 
@@ -264,8 +272,4 @@
     ! Integer type, the array has rank 1.
 
-    use netcdf, only: NF90_GET_VAR
-    use simple, only: nf95_inquire_variable, nf95_inquire_dimension
-    use handle_err_m, only: handle_err
-
     integer, intent(in):: ncid
     integer, intent(in):: varid
@@ -273,6 +277,6 @@
 
     ! Variables local to the procedure:
-    integer ierr, len
-    integer, pointer :: dimids(:)
+    integer nclen
+    integer, pointer:: dimids(:)
 
     !---------------------
@@ -281,16 +285,15 @@
 
     if (size(dimids) /= 1) then
-       print *, "nf95_gw_var_int_1d: NetCDF variable is not of rank 1"
-       stop 1
-    end if
-
-    call nf95_inquire_dimension(ncid, dimids(1), len=len)
-    deallocate(dimids) ! pointer
-
-    allocate(values(len))
-    if (len /= 0) then
-       ierr = NF90_GET_VAR(ncid, varid, values)
-       call handle_err("NF90_GET_VAR", ierr, ncid, varid)
-    end if
+       print *, "nf95_gw_var_int_1d:"
+       print *, "varid = ", varid
+       print *, "rank of NetCDF variable is ", size(dimids), ", not 1"
+       stop 1
+    end if
+
+    call nf95_inquire_dimension(ncid, dimids(1), nclen=nclen)
+    deallocate(dimids) ! pointer
+
+    allocate(values(nclen))
+    if (nclen /= 0) call NF95_GET_VAR(ncid, varid, values)
 
   end subroutine nf95_gw_var_int_1d
@@ -302,8 +305,4 @@
     ! Integer type, the array has rank 3.
 
-    use netcdf, only: NF90_GET_VAR
-    use simple, only: nf95_inquire_variable, nf95_inquire_dimension
-    use handle_err_m, only: handle_err
-
     integer, intent(in):: ncid
     integer, intent(in):: varid
@@ -311,6 +310,6 @@
 
     ! Variables local to the procedure:
-    integer ierr, len1, len2, len3
-    integer, pointer :: dimids(:)
+    integer nclen1, nclen2, nclen3
+    integer, pointer:: dimids(:)
 
     !---------------------
@@ -319,18 +318,17 @@
 
     if (size(dimids) /= 3) then
-       print *, "nf95_gw_var_int_3d: NetCDF variable is not of rank 3"
-       stop 1
-    end if
-
-    call nf95_inquire_dimension(ncid, dimids(1), len=len1)
-    call nf95_inquire_dimension(ncid, dimids(2), len=len2)
-    call nf95_inquire_dimension(ncid, dimids(3), len=len3)
-    deallocate(dimids) ! pointer
-
-    allocate(values(len1, len2, len3))
-    if (len1 * len2 * len3 /= 0) then
-       ierr = NF90_GET_VAR(ncid, varid, values)
-       call handle_err("NF90_GET_VAR", ierr, ncid, varid)
-    end if
+       print *, "nf95_gw_var_int_3d:"
+       print *, "varid = ", varid
+       print *, "rank of NetCDF variable is ", size(dimids), ", not 3"
+       stop 1
+    end if
+
+    call nf95_inquire_dimension(ncid, dimids(1), nclen=nclen1)
+    call nf95_inquire_dimension(ncid, dimids(2), nclen=nclen2)
+    call nf95_inquire_dimension(ncid, dimids(3), nclen=nclen3)
+    deallocate(dimids) ! pointer
+
+    allocate(values(nclen1, nclen2, nclen3))
+    if (nclen1 * nclen2 * nclen3 /= 0) call NF95_GET_VAR(ncid, varid, values)
 
   end subroutine nf95_gw_var_int_3d
Index: LMDZ5/branches/testing/libf/bibio/nf95_put_var_m.F90
===================================================================
--- LMDZ5/branches/testing/libf/bibio/nf95_put_var_m.F90	(revision 1665)
+++ LMDZ5/branches/testing/libf/bibio/nf95_put_var_m.F90	(revision 1669)
@@ -9,8 +9,4 @@
           nf95_put_var_2D_FourByteReal, nf95_put_var_3D_FourByteReal, &
           nf95_put_var_4D_FourByteReal
-!!$     module procedure nf95_put_var_1D_FourByteReal, &
-!!$          nf95_put_var_2D_FourByteReal, nf95_put_var_3D_FourByteReal, &
-!!$          nf95_put_var_4D_FourByteReal, nf90_put_var_1D_EightByteReal, &
-!!$          nf90_put_var_3D_EightByteReal
   end interface
 
@@ -25,7 +21,7 @@
     use handle_err_m, only: handle_err
 
-    integer, intent( in) :: ncid, varid
-    real, intent( in) :: values
-    integer, dimension(:), optional, intent( in) :: start
+    integer, intent(in) :: ncid, varid
+    real, intent(in) :: values
+    integer, dimension(:), optional, intent(in) :: start
     integer, intent(out), optional:: ncerr
 
@@ -52,7 +48,7 @@
     use handle_err_m, only: handle_err
 
-    integer, intent( in) :: ncid, varid
-    integer, intent( in) :: values
-    integer, dimension(:), optional, intent( in) :: start
+    integer, intent(in) :: ncid, varid
+    integer, intent(in) :: values
+    integer, dimension(:), optional, intent(in) :: start
     integer, intent(out), optional:: ncerr
 
@@ -74,6 +70,6 @@
   !***********************
 
-  subroutine nf95_put_var_1D_FourByteReal(ncid, varid, values, start, count, &
-       stride, map, ncerr)
+  subroutine nf95_put_var_1D_FourByteReal(ncid, varid, values, start, &
+       count_nc, stride, map, ncerr)
 
     use netcdf, only: nf90_put_var
@@ -82,14 +78,14 @@
     integer,                         intent(in) :: ncid, varid
     real, intent(in) :: values(:)
-    integer, dimension(:), optional, intent(in) :: start, count, stride, map
-    integer, intent(out), optional:: ncerr
-
-    ! Variable local to the procedure:
-    integer ncerr_not_opt
-
-    !-------------------
-
-    ncerr_not_opt = nf90_put_var(ncid, varid, values, start, count, stride, &
-         map)
+    integer, dimension(:), optional, intent(in) :: start, count_nc, stride, map
+    integer, intent(out), optional:: ncerr
+
+    ! Variable local to the procedure:
+    integer ncerr_not_opt
+
+    !-------------------
+
+    ncerr_not_opt = nf90_put_var(ncid, varid, values, start, count_nc, &
+         stride, map)
     if (present(ncerr)) then
        ncerr = ncerr_not_opt
@@ -103,6 +99,6 @@
   !***********************
 
-  subroutine nf95_put_var_1D_FourByteInt(ncid, varid, values, start, count, &
-       stride, map, ncerr)
+  subroutine nf95_put_var_1D_FourByteInt(ncid, varid, values, start, &
+       count_nc, stride, map, ncerr)
 
     use netcdf, only: nf90_put_var
@@ -111,14 +107,14 @@
     integer,                         intent(in) :: ncid, varid
     integer, intent(in) :: values(:)
-    integer, dimension(:), optional, intent(in) :: start, count, stride, map
-    integer, intent(out), optional:: ncerr
-
-    ! Variable local to the procedure:
-    integer ncerr_not_opt
-
-    !-------------------
-
-    ncerr_not_opt = nf90_put_var(ncid, varid, values, start, count, stride, &
-         map)
+    integer, dimension(:), optional, intent(in) :: start, count_nc, stride, map
+    integer, intent(out), optional:: ncerr
+
+    ! Variable local to the procedure:
+    integer ncerr_not_opt
+
+    !-------------------
+
+    ncerr_not_opt = nf90_put_var(ncid, varid, values, start, count_nc, &
+         stride, map)
     if (present(ncerr)) then
        ncerr = ncerr_not_opt
@@ -132,22 +128,52 @@
   !***********************
 
-  subroutine nf95_put_var_2D_FourByteReal(ncid, varid, values, start, count, &
-       stride, map, ncerr)
-
-    use netcdf, only: nf90_put_var
-    use handle_err_m, only: handle_err
-
-    integer,                         intent( in) :: ncid, varid
-    real, intent( in) :: values(:, :)
-    integer, dimension(:), optional, intent( in) :: start, count, stride, map
-    integer, intent(out), optional:: ncerr
-
-    ! Variable local to the procedure:
-    integer ncerr_not_opt
-
-    !-------------------
-
-    ncerr_not_opt = nf90_put_var(ncid, varid, values, start, count, stride, &
-         map)
+  subroutine nf95_put_var_1D_EightByteReal(ncid, varid, values, start, &
+       count_nc, stride, map, ncerr)
+
+    use typesizes, only: eightByteReal
+    use netcdf, only: nf90_put_var
+    use handle_err_m, only: handle_err
+
+    integer,                         intent(in) :: ncid, varid
+    real (kind = EightByteReal),     intent(in) :: values(:)
+    integer, dimension(:), optional, intent(in):: start, count_nc, stride, map
+    integer, intent(out), optional:: ncerr
+
+    ! Variable local to the procedure:
+    integer ncerr_not_opt
+
+    !-------------------
+
+    ncerr_not_opt = nf90_put_var(ncid, varid, values, start, count_nc, &
+         stride, map)
+    if (present(ncerr)) then
+       ncerr = ncerr_not_opt
+    else
+       call handle_err("nf95_put_var_1D_eightByteReal", ncerr_not_opt, ncid, &
+            varid)
+    end if
+
+  end subroutine nf95_put_var_1D_EightByteReal
+
+  !***********************
+
+  subroutine nf95_put_var_2D_FourByteReal(ncid, varid, values, start, &
+       count_nc, stride, map, ncerr)
+
+    use netcdf, only: nf90_put_var
+    use handle_err_m, only: handle_err
+
+    integer,                         intent(in) :: ncid, varid
+    real, intent(in) :: values(:, :)
+    integer, dimension(:), optional, intent(in) :: start, count_nc, stride, map
+    integer, intent(out), optional:: ncerr
+
+    ! Variable local to the procedure:
+    integer ncerr_not_opt
+
+    !-------------------
+
+    ncerr_not_opt = nf90_put_var(ncid, varid, values, start, count_nc, &
+         stride, map)
     if (present(ncerr)) then
        ncerr = ncerr_not_opt
@@ -161,22 +187,52 @@
   !***********************
 
-  subroutine nf95_put_var_3D_FourByteReal(ncid, varid, values, start, count, &
-       stride, map, ncerr)
-
-    use netcdf, only: nf90_put_var
-    use handle_err_m, only: handle_err
-
-    integer,                         intent( in) :: ncid, varid
-    real, intent( in) :: values(:, :, :)
-    integer, dimension(:), optional, intent( in) :: start, count, stride, map
-    integer, intent(out), optional:: ncerr
-
-    ! Variable local to the procedure:
-    integer ncerr_not_opt
-
-    !-------------------
-
-    ncerr_not_opt = nf90_put_var(ncid, varid, values, start, count, stride, &
-         map)
+  subroutine nf95_put_var_2D_EightByteReal(ncid, varid, values, start, &
+       count_nc, stride, map, ncerr)
+
+    use typesizes, only: EightByteReal
+    use netcdf, only: nf90_put_var
+    use handle_err_m, only: handle_err
+
+    integer,                         intent(in) :: ncid, varid
+    real (kind = EightByteReal), intent(in) :: values(:, :)
+    integer, dimension(:), optional, intent(in) :: start, count_nc, stride, map
+    integer, intent(out), optional:: ncerr
+
+    ! Variable local to the procedure:
+    integer ncerr_not_opt
+
+    !-------------------
+
+    ncerr_not_opt = nf90_put_var(ncid, varid, values, start, count_nc, &
+         stride, map)
+    if (present(ncerr)) then
+       ncerr = ncerr_not_opt
+    else
+       call handle_err("nf95_put_var_2D_EightByteReal", ncerr_not_opt, ncid, &
+            varid)
+    end if
+
+  end subroutine nf95_put_var_2D_EightByteReal
+
+  !***********************
+
+  subroutine nf95_put_var_3D_FourByteReal(ncid, varid, values, start, &
+       count_nc, stride, map, ncerr)
+
+    use netcdf, only: nf90_put_var
+    use handle_err_m, only: handle_err
+
+    integer,                         intent(in) :: ncid, varid
+    real, intent(in) :: values(:, :, :)
+    integer, dimension(:), optional, intent(in) :: start, count_nc, stride, map
+    integer, intent(out), optional:: ncerr
+
+    ! Variable local to the procedure:
+    integer ncerr_not_opt
+
+    !-------------------
+
+    ncerr_not_opt = nf90_put_var(ncid, varid, values, start, count_nc, &
+         stride, map)
     if (present(ncerr)) then
        ncerr = ncerr_not_opt
@@ -190,22 +246,52 @@
   !***********************
 
-  subroutine nf95_put_var_4D_FourByteReal(ncid, varid, values, start, count, &
-       stride, map, ncerr)
-
-    use netcdf, only: nf90_put_var
-    use handle_err_m, only: handle_err
-
-    integer,                         intent( in) :: ncid, varid
-    real, intent( in) :: values(:, :, :, :)
-    integer, dimension(:), optional, intent( in) :: start, count, stride, map
-    integer, intent(out), optional:: ncerr
-
-    ! Variable local to the procedure:
-    integer ncerr_not_opt
-
-    !-------------------
-
-    ncerr_not_opt = nf90_put_var(ncid, varid, values, start, count, stride, &
-         map)
+  subroutine nf95_put_var_3D_EightByteReal(ncid, varid, values, start, &
+       count_nc, stride, map, ncerr)
+
+    use typesizes, only: eightByteReal
+    use netcdf, only: nf90_put_var
+    use handle_err_m, only: handle_err
+
+    integer,                         intent(in) :: ncid, varid
+    real (kind = EightByteReal),     intent(in) :: values(:, :, :)
+    integer, dimension(:), optional, intent(in) :: start, count_nc, stride, map
+    integer, intent(out), optional:: ncerr
+
+    ! Variable local to the procedure:
+    integer ncerr_not_opt
+
+    !-------------------
+
+    ncerr_not_opt = nf90_put_var(ncid, varid, values, start, count_nc, &
+         stride, map)
+    if (present(ncerr)) then
+       ncerr = ncerr_not_opt
+    else
+       call handle_err("nf95_put_var_3D_eightByteReal", ncerr_not_opt, ncid, &
+            varid)
+    end if
+
+  end subroutine nf95_put_var_3D_EightByteReal
+
+  !***********************
+
+  subroutine nf95_put_var_4D_FourByteReal(ncid, varid, values, start, &
+       count_nc, stride, map, ncerr)
+
+    use netcdf, only: nf90_put_var
+    use handle_err_m, only: handle_err
+
+    integer,                         intent(in) :: ncid, varid
+    real, intent(in) :: values(:, :, :, :)
+    integer, dimension(:), optional, intent(in) :: start, count_nc, stride, map
+    integer, intent(out), optional:: ncerr
+
+    ! Variable local to the procedure:
+    integer ncerr_not_opt
+
+    !-------------------
+
+    ncerr_not_opt = nf90_put_var(ncid, varid, values, start, count_nc, &
+         stride, map)
     if (present(ncerr)) then
        ncerr = ncerr_not_opt
@@ -219,61 +305,31 @@
   !***********************
 
-!!$  subroutine nf90_put_var_1D_EightByteReal(ncid, varid, values, start, count, &
-!!$       stride, map, ncerr)
-!!$
-!!$    use typesizes, only: eightByteReal
-!!$    use netcdf, only: nf90_put_var
-!!$    use handle_err_m, only: handle_err
-!!$
-!!$    integer,                         intent( in) :: ncid, varid
-!!$    real (kind = EightByteReal),     intent( in) :: values(:)
-!!$    integer, dimension(:), optional, intent( in) :: start, count, stride, map
-!!$    integer, intent(out), optional:: ncerr
-!!$
-!!$    ! Variable local to the procedure:
-!!$    integer ncerr_not_opt
-!!$
-!!$    !-------------------
-!!$
-!!$    ncerr_not_opt = nf90_put_var(ncid, varid, values, start, count, stride, &
-!!$         map)
-!!$    if (present(ncerr)) then
-!!$       ncerr = ncerr_not_opt
-!!$    else
-!!$       call handle_err("nf95_put_var_1D_eightByteReal", ncerr_not_opt, ncid, &
-!!$            varid)
-!!$    end if
-!!$
-!!$  end subroutine nf90_put_var_1D_EightByteReal
-!!$
-!!$  !***********************
-!!$
-!!$  subroutine nf90_put_var_3D_EightByteReal(ncid, varid, values, start, count, &
-!!$       stride, map, ncerr)
-!!$
-!!$    use typesizes, only: eightByteReal
-!!$    use netcdf, only: nf90_put_var
-!!$    use handle_err_m, only: handle_err
-!!$
-!!$    integer,                         intent( in) :: ncid, varid
-!!$    real (kind = EightByteReal),     intent( in) :: values(:, :, :)
-!!$    integer, dimension(:), optional, intent( in) :: start, count, stride, map
-!!$    integer, intent(out), optional:: ncerr
-!!$
-!!$    ! Variable local to the procedure:
-!!$    integer ncerr_not_opt
-!!$
-!!$    !-------------------
-!!$
-!!$    ncerr_not_opt = nf90_put_var(ncid, varid, values, start, count, stride, &
-!!$         map)
-!!$    if (present(ncerr)) then
-!!$       ncerr = ncerr_not_opt
-!!$    else
-!!$       call handle_err("nf95_put_var_3D_eightByteReal", ncerr_not_opt, ncid, &
-!!$            varid)
-!!$    end if
-!!$
-!!$  end subroutine nf90_put_var_3D_EightByteReal
+  subroutine nf95_put_var_4D_EightByteReal(ncid, varid, values, start, &
+       count_nc, stride, map, ncerr)
+
+    use typesizes, only: EightByteReal
+    use netcdf, only: nf90_put_var
+    use handle_err_m, only: handle_err
+
+    integer, intent(in):: ncid, varid
+    real(kind = EightByteReal), intent(in):: values(:, :, :, :)
+    integer, dimension(:), optional, intent(in):: start, count_nc, stride, map
+    integer, intent(out), optional:: ncerr
+
+    ! Variable local to the procedure:
+    integer ncerr_not_opt
+
+    !-------------------
+
+    ncerr_not_opt = nf90_put_var(ncid, varid, values, start, count_nc, &
+         stride, map)
+    if (present(ncerr)) then
+       ncerr = ncerr_not_opt
+    else
+       call handle_err("nf95_put_var_4D_EightByteReal", ncerr_not_opt, ncid, &
+            varid)
+    end if
+
+  end subroutine nf95_put_var_4D_EightByteReal
 
 end module nf95_put_var_m
Index: LMDZ5/branches/testing/libf/bibio/simple.F90
===================================================================
--- LMDZ5/branches/testing/libf/bibio/simple.F90	(revision 1665)
+++ LMDZ5/branches/testing/libf/bibio/simple.F90	(revision 1669)
@@ -2,6 +2,10 @@
 module simple
 
+  use handle_err_m, only: handle_err
+  
   implicit none
 
+  private handle_err
+
 contains
 
@@ -9,5 +13,4 @@
 
     use netcdf, only: nf90_open
-    use handle_err_m, only: handle_err
 
     character(len=*), intent(in):: path
@@ -36,8 +39,7 @@
 
     use netcdf, only: nf90_inq_dimid
-    use handle_err_m, only: handle_err
-
-    integer,             intent( in) :: ncid
-    character (len = *), intent( in) :: name
+
+    integer,             intent(in) :: ncid
+    character (len = *), intent(in) :: name
     integer,             intent(out) :: dimid
     integer, intent(out), optional:: ncerr
@@ -52,5 +54,5 @@
        ncerr = ncerr_not_opt
     else
-       call handle_err("nf95_inq_dimid", ncerr_not_opt, ncid)
+       call handle_err("nf95_inq_dimid " // name, ncerr_not_opt, ncid)
     end if
 
@@ -59,20 +61,19 @@
   !************************
 
-  subroutine nf95_inquire_dimension(ncid, dimid, name, len, ncerr)
+  subroutine nf95_inquire_dimension(ncid, dimid, name, nclen, ncerr)
 
     use netcdf, only: nf90_inquire_dimension
-    use handle_err_m, only: handle_err
 
     integer,                       intent( in) :: ncid, dimid
     character (len = *), optional, intent(out) :: name
-    integer,             optional, intent(out) :: len
-    integer, intent(out), optional:: ncerr
-
-    ! Variable local to the procedure:
-    integer ncerr_not_opt
-
-    !-------------------
-
-    ncerr_not_opt = nf90_inquire_dimension(ncid, dimid, name, len)
+    integer,             optional, intent(out) :: nclen
+    integer, intent(out), optional:: ncerr
+
+    ! Variable local to the procedure:
+    integer ncerr_not_opt
+
+    !-------------------
+
+    ncerr_not_opt = nf90_inquire_dimension(ncid, dimid, name, nclen)
     if (present(ncerr)) then
        ncerr = ncerr_not_opt
@@ -88,8 +89,7 @@
 
     use netcdf, only: nf90_inq_varid
-    use handle_err_m, only: handle_err
 
     integer,             intent(in) :: ncid
-    character (len = *), intent(in) :: name
+    character(len=*), intent(in):: name
     integer,             intent(out) :: varid
     integer, intent(out), optional:: ncerr
@@ -115,5 +115,6 @@
 
     ! In "nf90_inquire_variable", "dimids" is an assumed-size array.
-    ! This is the classical case of an array the size of which is
+    ! This is not optimal.
+    ! We are in the classical case of an array the size of which is
     ! unknown in the calling procedure, before the call.
     ! Here we use a better solution: a pointer argument array.
@@ -121,5 +122,4 @@
 
     use netcdf, only: nf90_inquire_variable, nf90_max_var_dims
-    use handle_err_m, only: handle_err
 
     integer, intent(in):: ncid, varid
@@ -151,5 +151,5 @@
        ncerr = ncerr_not_opt
     else
-       call handle_err("nf95_inquire_variable", ncerr_not_opt, ncid)
+       call handle_err("nf95_inquire_variable", ncerr_not_opt, ncid, varid)
     end if
 
@@ -161,5 +161,4 @@
     
     use netcdf, only: nf90_create
-    use handle_err_m, only: handle_err
 
     character (len = *), intent(in   ) :: path
@@ -186,12 +185,11 @@
   !************************
 
-  subroutine nf95_def_dim(ncid, name, len, dimid, ncerr)
+  subroutine nf95_def_dim(ncid, name, nclen, dimid, ncerr)
 
     use netcdf, only: nf90_def_dim
-    use handle_err_m, only: handle_err
 
     integer,             intent( in) :: ncid
     character (len = *), intent( in) :: name
-    integer,             intent( in) :: len
+    integer,             intent( in) :: nclen
     integer,             intent(out) :: dimid
     integer, intent(out), optional :: ncerr
@@ -202,9 +200,9 @@
     !-------------------
 
-    ncerr_not_opt = nf90_def_dim(ncid, name, len, dimid)
-    if (present(ncerr)) then
-       ncerr = ncerr_not_opt
-    else
-       call handle_err("nf95_def_dim", ncerr_not_opt, ncid)
+    ncerr_not_opt = nf90_def_dim(ncid, name, nclen, dimid)
+    if (present(ncerr)) then
+       ncerr = ncerr_not_opt
+    else
+       call handle_err("nf95_def_dim " // name, ncerr_not_opt, ncid)
     end if
 
@@ -216,5 +214,4 @@
 
     use netcdf, only: nf90_redef
-    use handle_err_m, only: handle_err
 
     integer, intent( in) :: ncid
@@ -240,5 +237,4 @@
 
     use netcdf, only: nf90_enddef
-    use handle_err_m, only: handle_err
 
     integer,           intent( in) :: ncid
@@ -265,5 +261,4 @@
 
     use netcdf, only: nf90_close
-    use handle_err_m, only: handle_err
 
     integer, intent( in) :: ncid
@@ -289,5 +284,4 @@
 
     use netcdf, only: nf90_copy_att
-    use handle_err_m, only: handle_err
 
     integer, intent( in):: ncid_in,  varid_in
@@ -305,8 +299,63 @@
        ncerr = ncerr_not_opt
     else
-       call handle_err("nf95_copy_att", ncerr_not_opt, ncid_out)
+       call handle_err("nf95_copy_att " // name, ncerr_not_opt, ncid_out)
     end if
 
   end subroutine nf95_copy_att
 
+  !***********************
+
+  subroutine nf95_inquire_attribute(ncid, varid, name, xtype, nclen, attnum, &
+       ncerr)
+
+    use netcdf, only: nf90_inquire_attribute
+
+    integer,             intent( in)           :: ncid, varid
+    character (len = *), intent( in)           :: name
+    integer,             intent(out), optional :: xtype, nclen, attnum
+    integer, intent(out), optional:: ncerr
+
+    ! Variable local to the procedure:
+    integer ncerr_not_opt
+
+    !-------------------
+
+    ncerr_not_opt = nf90_inquire_attribute(ncid, varid, name, xtype, nclen, &
+         attnum)
+    if (present(ncerr)) then
+       ncerr = ncerr_not_opt
+    else
+       call handle_err("nf95_inquire_attribute " // name, ncerr_not_opt, &
+            ncid, varid)
+    end if
+
+  end subroutine nf95_inquire_attribute
+
+  !***********************
+
+  subroutine nf95_inquire(ncid, nDimensions, nVariables, nAttributes, &
+       unlimitedDimId, formatNum, ncerr)
+
+    use netcdf, only: nf90_inquire
+
+    integer,           intent( in) :: ncid
+    integer, optional, intent(out) :: nDimensions, nVariables, nAttributes
+    integer, optional, intent(out) :: unlimitedDimId, formatNum
+    integer, intent(out), optional:: ncerr
+
+    ! Variable local to the procedure:
+    integer ncerr_not_opt
+
+    !-------------------
+
+    ncerr_not_opt = nf90_inquire(ncid, nDimensions, nVariables, nAttributes, &
+         unlimitedDimId, formatNum)
+    if (present(ncerr)) then
+       ncerr = ncerr_not_opt
+    else
+       call handle_err("nf95_inquire", ncerr_not_opt, ncid)
+    end if
+
+  end subroutine nf95_inquire
+
 end module simple
