Index: LMDZ5/trunk/libf/bibio/simple.F90
===================================================================
--- LMDZ5/trunk/libf/bibio/simple.F90	(revision 1434)
+++ LMDZ5/trunk/libf/bibio/simple.F90	(revision 1635)
@@ -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
