Index: LMDZ6/branches/Amaury_dev/libf/misc/formcoord.f90
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/misc/formcoord.f90	(revision 5115)
+++ 	(revision )
@@ -1,54 +1,0 @@
-
-! $Header$
-
-SUBROUTINE formcoord(unit,n,x,a,rev,text)
-  IMPLICIT NONE
-  integer :: n,unit,ndec
-  logical :: rev
-  real :: x(n),a
-  character(len=4) :: text
-
-  integer :: i,id,i1,i2,in
-  real :: dx,dxmin
-
-  if(rev) then
-     id=-1
-     i1=n
-     i2=n-1
-     in=1
-     write(unit,3000) text(1:1)
-  else
-     id=1
-     i1=1
-     i2=2
-     in=n
-  endif
-
-  if (n<2) then
-     ndec=1
-     write(unit,1000) text,n,x(1)*a
-  else
-     dxmin=abs(x(2)-x(1))
-     do i=2,n-1
-        dx=abs(x(i+1)-x(i))
-        if (dx<dxmin) dxmin=dx
-     enddo
-
-     ndec=-log10(dxmin)+2
-     if(mod(n,6)==1) then
-        write(unit,1000) text,n,x(i1)*a
-        write(unit,2000) (x(i)*a,i=i2,in,id)
-     else
-        write(unit,1000) text,n
-        write(unit,2000) (x(i)*a,i=i1,in,id)
-     endif
-  endif
-
-1000   format(a4,2x,i4,' LEVELS',43x,f12.2)
-2000   format(6f12.2)
-  !1000  format(a4,2x,i4,' LEVELS',43x,f12.<ndec>)
-  !2000  format(6f12.<ndec>)
-3000   format('FORMAT ',a1,'REV')
-
-
-end subroutine formcoord
Index: LMDZ6/branches/Amaury_dev/libf/misc/interpolation.F90
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/misc/interpolation.F90	(revision 5115)
+++ 	(revision )
@@ -1,138 +1,0 @@
-! $Id$
-module interpolation
-
-  ! From Press et al., 1996, version 2.10a
-  ! B3 Interpolation and Extrapolation
-
-  IMPLICIT NONE 
-
-contains
-
-  pure FUNCTION locate(xx,x)
-
-    REAL, DIMENSION(:), INTENT(IN) :: xx
-    REAL, INTENT(IN) :: x
-    INTEGER  locate
-
-    ! Given an array xx(1:N), and given a value x, returns a value j,
-    ! between 0 and N, such that x is between xx(j) and xx(j + 1). xx
-    ! must be monotonic, either increasing or decreasing. j = 0 or j =
-    ! N is returned to indicate that x is out of range. This
-    ! procedure should not be called with a zero-sized array argument.
-    ! See notes.
-
-    INTEGER  n,jl,jm,ju
-    LOGICAL  ascnd
-
-    !----------------------------
-
-    n=size(xx)
-    ascnd = (xx(n) >= xx(1))
-    ! (True if ascending order of table, false otherwise.)
-    ! Initialize lower and upper limits:
-    jl=0
-    ju=n+1
-    do while (ju-jl > 1)
-       jm=(ju+jl)/2 ! Compute a midpoint,
-       if (ascnd .eqv. (x >= xx(jm))) then
-          jl=jm ! and replace either the lower limit
-       else
-          ju=jm ! or the upper limit, as appropriate.
-       end if
-    END DO
-    ! {ju == jl + 1}
-
-    ! {(ascnd .and. xx(jl) <= x < xx(jl+1)) 
-    !  .neqv. 
-    !  (.not. ascnd .and. xx(jl+1) <= x < xx(jl))}
-
-    ! Then set the output, being careful with the endpoints:
-    if (x == xx(1)) then
-       locate=1
-    else if (x == xx(n)) then
-       locate=n-1
-    else
-       locate=jl
-    end if
-
-  END FUNCTION locate
-
-  !***************************
-
-  pure SUBROUTINE hunt(xx,x,jlo)
-
-    ! Given an array xx(1:N ), and given a value x, returns a value
-    ! jlo such that x is between xx(jlo) and xx(jlo+1). xx must be
-    ! monotonic, either increasing or decreasing. jlo = 0 or jlo = N is
-    ! returned to indicate that x is out of range. jlo on input is taken as
-    ! the initial guess for jlo on output.
-    ! Modified so that it uses the information "jlo = 0" on input.
-
-    INTEGER, INTENT(INOUT) :: jlo
-    REAL, INTENT(IN) :: x
-    REAL, DIMENSION(:), INTENT(IN) :: xx
-    INTEGER  n,inc,jhi,jm
-    LOGICAL  ascnd, hunt_up
-
-    !-----------------------------------------------------
-
-    n=size(xx)
-    ascnd = (xx(n) >= xx(1))
-    ! (True if ascending order of table, false otherwise.)
-    if (jlo < 0 .or. jlo > n) then
-       ! Input guess not useful. Go immediately to bisection.
-       jlo=0
-       jhi=n+1
-    else
-       inc=1 ! Set the hunting increment.
-       if (jlo == 0) then
-          hunt_up = .TRUE.
-       else
-          hunt_up = x >= xx(jlo) .eqv. ascnd
-       end if
-       if (hunt_up) then ! Hunt up:
-          do
-             jhi=jlo+inc
-             if (jhi > n) then ! Done hunting, since off end of table.
-                jhi=n+1
-                exit
-             else
-                if (x < xx(jhi) .eqv. ascnd) exit
-                jlo=jhi ! Not done hunting,
-                inc=inc+inc ! so double the increment
-             end if
-          END DO ! and try again.
-       else ! Hunt down:
-          jhi=jlo
-          do
-             jlo=jhi-inc
-             if (jlo < 1) then ! Done hunting, since off end of table.
-                jlo=0
-                exit
-             else
-                if (x >= xx(jlo) .eqv. ascnd) exit
-                jhi=jlo ! Not done hunting,
-                inc=inc+inc ! so double the increment
-             end if
-          END DO ! and try again.
-       end if
-    end if ! Done hunting, value bracketed.
-
-    do ! Hunt is done, so begin the final bisection phase:
-       if (jhi-jlo <= 1) then
-          if (x == xx(n)) jlo=n-1
-          if (x == xx(1)) jlo=1
-          exit
-       else
-          jm=(jhi+jlo)/2
-          if (x >= xx(jm) .eqv. ascnd) then
-             jlo=jm
-          else
-             jhi=jm
-          end if
-       end if
-    END DO
-
-  END SUBROUTINE hunt
-
-end module interpolation
Index: LMDZ6/branches/Amaury_dev/libf/misc/ismax.f90
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/misc/ismax.f90	(revision 5115)
+++ 	(revision )
@@ -1,24 +1,0 @@
-
-! $Header$
-
-function ismax(n,sx,incx)
-  !
-  IMPLICIT NONE
-  !
-  INTEGER :: n,i,incx,ismax,ix
-  real :: sx((n-1)*incx+1),sxmax
-  !
-  ix=1
-  ismax=1
-  sxmax=sx(1)
-  do i=1,n-1
-   ix=ix+incx
-   if(sx(ix)>sxmax) then
-     sxmax=sx(ix)
-     ismax=i+1
-   endif
-  END DO
-  !
-
-end function ismax
-
Index: LMDZ6/branches/Amaury_dev/libf/misc/ismin.f90
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/misc/ismin.f90	(revision 5115)
+++ 	(revision )
@@ -1,24 +1,0 @@
-
-! $Header$
-
-FUNCTION ismin(n,sx,incx)
-  !
-  IMPLICIT NONE
-  !
-  integer :: n,i,incx,ismin,ix
-  real :: sx((n-1)*incx+1),sxmin
-  !
-  ix=1
-  ismin=1
-  sxmin=sx(1)
-  DO i=1,n-1
-     ix=ix+incx
-     if(sx(ix)<sxmin) then
-         sxmin=sx(ix)
-         ismin=i+1
-     endif
-  ENDDO
-  !
-
-end function ismin
-!
Index: LMDZ6/branches/Amaury_dev/libf/misc/j4save.f90
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/misc/j4save.f90	(revision 5115)
+++ 	(revision )
@@ -1,67 +1,0 @@
-!DECK J4SAVE
-FUNCTION J4SAVE(IWHICH, IVALUE, ISET)
-  IMPLICIT NONE
-  !***BEGIN PROLOGUE  J4SAVE
-  !***SUBSIDIARY
-  !***PURPOSE  Save or reCALL global variables needed by error
-         ! handling routines.
-  !***LIBRARY   SLATEC (XERROR)
-  !***TYPE      INTEGER (J4SAVE-I)
-  !***KEYWORDS  ERROR MESSAGES, ERROR NUMBER, RECALL, SAVE, XERROR
-  !***AUTHOR  Jones, R. E., (SNLA)
-  !***DESCRIPTION
-  !
-  ! Abstract
-  !    J4SAVE saves and recalls several global variables needed
-  !    by the library error handling routines.
-  !
-  ! Description of Parameters
-  !  --Input--
-  !    IWHICH - Index of item desired.
-  !            = 1 Refers to current error number.
-  !            = 2 Refers to current error control flag.
-  !            = 3 Refers to current unit number to which error
-  !                messages are to be sent.  (0 means use standard.)
-  !            = 4 Refers to the maximum number of times any
-  !                 message is to be printed (as set by XERMAX).
-  !            = 5 Refers to the total number of units to which
-  !                 each error message is to be written.
-  !            = 6 Refers to the 2nd unit for error messages
-  !            = 7 Refers to the 3rd unit for error messages
-  !            = 8 Refers to the 4th unit for error messages
-  !            = 9 Refers to the 5th unit for error messages
-  !    IVALUE - The value to be set for the IWHICH-th parameter,
-  !             if ISET is .TRUE. .
-  !    ISET   - If ISET=.TRUE., the IWHICH-th parameter will BE
-  !             given the value, IVALUE.  If ISET=.FALSE., the
-  !             IWHICH-th parameter will be unchanged, and IVALUE
-  !             is a dummy parameter.
-  !  --Output--
-  !    The (old) value of the IWHICH-th parameter will be returned
-  !    in the function value, J4SAVE.
-  !
-  !***SEE ALSO  XERMSG
-  !***REFERENCES  R. E. Jones and D. K. Kahaner, XERROR, the SLATEC
-  !             Error-handling Package, SAND82-0800, Sandia
-  !             Laboratories, 1982.
-  !***ROUTINES CALLED  (NONE)
-  !***REVISION HISTORY  (YYMMDD)
-  !   790801  DATE WRITTEN
-  !   891214  Prologue converted to Version 4.0 format.  (BAB)
-  !   900205  Minor modifications to prologue.  (WRB)
-  !   900402  Added TYPE section.  (WRB)
-  !   910411  Added KEYWORDS section.  (WRB)
-  !   920501  Reformatted the REFERENCES section.  (WRB)
-  !***END PROLOGUE  J4SAVE
-  LOGICAL :: ISET
-  INTEGER :: IPARAM(9)
-  SAVE IPARAM
-  DATA IPARAM(1),IPARAM(2),IPARAM(3),IPARAM(4)/0,2,0,10/
-  DATA IPARAM(5)/1/
-  DATA IPARAM(6),IPARAM(7),IPARAM(8),IPARAM(9)/0,0,0,0/
-  INTEGER :: J4SAVE,IWHICH,IVALUE
-  !***FIRST EXECUTABLE STATEMENT  J4SAVE
-  J4SAVE = IPARAM(IWHICH)
-  IF (ISET) IPARAM(IWHICH) = IVALUE
-
-END FUNCTION J4SAVE
Index: LMDZ6/branches/Amaury_dev/libf/misc/juldate.f90
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/misc/juldate.f90	(revision 5115)
+++ 	(revision )
@@ -1,39 +1,0 @@
-
-! $Id$
-
-  SUBROUTINE juldate(ian,imoi,ijou,oh,om,os,tjd,tjdsec)
-  ! Sous-routine de changement de date:
-  ! gregorien>>>date julienne
-  ! En entree:an,mois,jour,heure,min.,sec.
-  ! En sortie:tjd
-    IMPLICIT NONE
-    INTEGER,INTENT(IN) :: ian,imoi,ijou,oh,om,os
-    REAL,INTENT(OUT) :: tjd,tjdsec
-
-    REAL :: frac,year,rmon,cf,a,b
-    INTEGER :: ojou
-
-    frac=((os/60.+om)/60.+oh)/24.
-    ojou=dble(ijou)+frac
-        year=dble(ian)
-        rmon=dble(imoi)
-    if (imoi <= 2) then
-        year=year-1.
-        rmon=rmon+12.
-    endif
-    cf=year+(rmon/100.)+(ojou/10000.)
-    if (cf >= 1582.1015) then
-        a=int(year/100)
-        b=2-a+int(a/4)
-    else
-        b=0
-    endif
-    tjd=int(365.25*year)+int(30.6001*(rmon+1))+int(ojou) &
-          +1720994.5+b
-    tjdsec=(ojou-int(ojou))+(tjd-int(tjd))
-    tjd=int(tjd)+int(tjdsec)
-    tjdsec=tjdsec-int(tjdsec)
-
-end subroutine juldate
-
-
Index: LMDZ6/branches/Amaury_dev/libf/misc/lmdz_assert.f90
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/misc/lmdz_assert.f90	(revision 5115)
+++ LMDZ6/branches/Amaury_dev/libf/misc/lmdz_assert.f90	(revision 5116)
@@ -15,5 +15,5 @@
     CHARACTER(LEN = *), INTENT(IN) :: string
     LOGICAL, INTENT(IN) :: n1
-    if (.not. n1) then
+    if (.not. n1) THEN
       write (*, *) 'nrerror: an assertion failed with this tag:', &
               string
@@ -26,5 +26,5 @@
     CHARACTER(LEN = *), INTENT(IN) :: string
     LOGICAL, INTENT(IN) :: n1, n2
-    if (.not. (n1 .and. n2)) then
+    if (.not. (n1 .and. n2)) THEN
       write (*, *) 'nrerror: an assertion failed with this tag:', &
               string
@@ -37,5 +37,5 @@
     CHARACTER(LEN = *), INTENT(IN) :: string
     LOGICAL, INTENT(IN) :: n1, n2, n3
-    if (.not. (n1 .and. n2 .and. n3)) then
+    if (.not. (n1 .and. n2 .and. n3)) THEN
       write (*, *) 'nrerror: an assertion failed with this tag:', &
               string
@@ -48,5 +48,5 @@
     CHARACTER(LEN = *), INTENT(IN) :: string
     LOGICAL, INTENT(IN) :: n1, n2, n3, n4
-    if (.not. (n1 .and. n2 .and. n3 .and. n4)) then
+    if (.not. (n1 .and. n2 .and. n3 .and. n4)) THEN
       write (*, *) 'nrerror: an assertion failed with this tag:', &
               string
@@ -59,5 +59,5 @@
     CHARACTER(LEN = *), INTENT(IN) :: string
     LOGICAL, DIMENSION(:), INTENT(IN) :: n
-    if (.not. all(n)) then
+    if (.not. all(n)) THEN
       write (*, *) 'nrerror: an assertion failed with this tag:', &
               string
Index: LMDZ6/branches/Amaury_dev/libf/misc/lmdz_coefpoly.f90
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/misc/lmdz_coefpoly.f90	(revision 5115)
+++ LMDZ6/branches/Amaury_dev/libf/misc/lmdz_coefpoly.f90	(revision 5116)
@@ -1,5 +1,6 @@
 module lmdz_coefpoly
 
-  IMPLICIT NONE
+  IMPLICIT NONE; PRIVATE
+  PUBLIC coefpoly
 
 contains
@@ -25,5 +26,5 @@
     ! a0, a1, a2, a3.
 
-    use nrtype, only: k8
+    use nrtype, ONLY: k8
 
     REAL(K8), intent(in) :: xf1, xf2, xprim1, xprim2, xtild1, xtild2
Index: LMDZ6/branches/Amaury_dev/libf/misc/lmdz_formcoord.f90
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/misc/lmdz_formcoord.f90	(revision 5116)
+++ LMDZ6/branches/Amaury_dev/libf/misc/lmdz_formcoord.f90	(revision 5116)
@@ -0,0 +1,54 @@
+MODULE lmdz_formcoord
+  IMPLICIT NONE; PRIVATE
+  PUBLIC formcoord
+CONTAINS
+
+  SUBROUTINE formcoord(unit, n, x, a, rev, text)
+    IMPLICIT NONE
+    INTEGER :: n, unit, ndec
+    logical :: rev
+    REAL :: x(n), a
+    CHARACTER(LEN = 4) :: text
+
+    INTEGER :: i, id, i1, i2, in
+    REAL :: dx, dxmin
+
+    IF(rev) THEN
+      id = -1
+      i1 = n
+      i2 = n - 1
+      in = 1
+      WRITE(unit, 3000) text(1:1)
+    else
+      id = 1
+      i1 = 1
+      i2 = 2
+      in = n
+    endif
+
+    if (n<2) THEN
+      ndec = 1
+      WRITE(unit, 1000) text, n, x(1) * a
+    else
+      dxmin = abs(x(2) - x(1))
+      do i = 2, n - 1
+        dx = abs(x(i + 1) - x(i))
+        if (dx<dxmin) dxmin = dx
+      enddo
+
+      ndec = -log10(dxmin) + 2
+      IF(mod(n, 6)==1) THEN
+        WRITE(unit, 1000) text, n, x(i1) * a
+        WRITE(unit, 2000) (x(i) * a, i=i2, in, id)
+      else
+        WRITE(unit, 1000) text, n
+        WRITE(unit, 2000) (x(i) * a, i=i1, in, id)
+      endif
+    endif
+
+    1000   format(a4, 2x, i4, ' LEVELS', 43x, f12.2)
+    2000   format(6f12.2)
+    3000   format('FORMAT ', a1, 'REV')
+
+  END SUBROUTINE formcoord
+END MODULE lmdz_formcoord
Index: LMDZ6/branches/Amaury_dev/libf/misc/lmdz_interpolation.f90
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/misc/lmdz_interpolation.f90	(revision 5116)
+++ LMDZ6/branches/Amaury_dev/libf/misc/lmdz_interpolation.f90	(revision 5116)
@@ -0,0 +1,139 @@
+! $Id$
+module lmdz_interpolation
+
+  ! From Press et al., 1996, version 2.10a
+  ! B3 Interpolation and Extrapolation
+
+  IMPLICIT NONE; PRIVATE
+  PUBLIC locate, hunt
+
+contains
+
+  pure FUNCTION locate(xx, x)
+
+    REAL, DIMENSION(:), INTENT(IN) :: xx
+    REAL, INTENT(IN) :: x
+    INTEGER  locate
+
+    ! Given an array xx(1:N), and given a value x, returns a value j,
+    ! between 0 and N, such that x is between xx(j) and xx(j + 1). xx
+    ! must be monotonic, either increasing or decreasing. j = 0 or j =
+    ! N is returned to indicate that x is out of range. This
+    ! procedure should not be called with a zero-sized array argument.
+    ! See notes.
+
+    INTEGER  n, jl, jm, ju
+    LOGICAL  ascnd
+
+    !----------------------------
+
+    n = size(xx)
+    ascnd = (xx(n) >= xx(1))
+    ! (True if ascending order of table, false otherwise.)
+    ! Initialize lower and upper limits:
+    jl = 0
+    ju = n + 1
+    do while (ju - jl > 1)
+      jm = (ju + jl) / 2 ! Compute a midpoint,
+      if (ascnd .eqv. (x >= xx(jm))) THEN
+        jl = jm ! and replace either the lower limit
+      else
+        ju = jm ! or the upper limit, as appropriate.
+      end if
+    END DO
+    ! {ju == jl + 1}
+
+    ! {(ascnd .and. xx(jl) <= x < xx(jl+1)) 
+    !  .neqv. 
+    !  (.not. ascnd .and. xx(jl+1) <= x < xx(jl))}
+
+    ! Then set the output, being careful with the endpoints:
+    if (x == xx(1)) THEN
+      locate = 1
+    else if (x == xx(n)) THEN
+      locate = n - 1
+    else
+      locate = jl
+    end if
+
+  END FUNCTION locate
+
+  !***************************
+
+  pure SUBROUTINE hunt(xx, x, jlo)
+
+    ! Given an array xx(1:N ), and given a value x, returns a value
+    ! jlo such that x is between xx(jlo) and xx(jlo+1). xx must be
+    ! monotonic, either increasing or decreasing. jlo = 0 or jlo = N is
+    ! returned to indicate that x is out of range. jlo on input is taken as
+    ! the initial guess for jlo on output.
+    ! Modified so that it uses the information "jlo = 0" on input.
+
+    INTEGER, INTENT(INOUT) :: jlo
+    REAL, INTENT(IN) :: x
+    REAL, DIMENSION(:), INTENT(IN) :: xx
+    INTEGER  n, inc, jhi, jm
+    LOGICAL  ascnd, hunt_up
+
+    !-----------------------------------------------------
+
+    n = size(xx)
+    ascnd = (xx(n) >= xx(1))
+    ! (True if ascending order of table, false otherwise.)
+    if (jlo < 0 .or. jlo > n) THEN
+      ! Input guess not useful. Go immediately to bisection.
+      jlo = 0
+      jhi = n + 1
+    else
+      inc = 1 ! Set the hunting increment.
+      if (jlo == 0) THEN
+        hunt_up = .TRUE.
+      else
+        hunt_up = x >= xx(jlo) .eqv. ascnd
+      end if
+      if (hunt_up) then ! Hunt up:
+        do
+          jhi = jlo + inc
+          if (jhi > n) then ! Done hunting, since off end of table.
+            jhi = n + 1
+            exit
+          else
+            if (x < xx(jhi) .eqv. ascnd) exit
+            jlo = jhi ! Not done hunting,
+            inc = inc + inc ! so double the increment
+          end if
+        END DO ! and try again.
+      else ! Hunt down:
+        jhi = jlo
+        do
+          jlo = jhi - inc
+          if (jlo < 1) then ! Done hunting, since off end of table.
+            jlo = 0
+            exit
+          else
+            if (x >= xx(jlo) .eqv. ascnd) exit
+            jhi = jlo ! Not done hunting,
+            inc = inc + inc ! so double the increment
+          end if
+        END DO ! and try again.
+      end if
+    end if ! Done hunting, value bracketed.
+
+    do ! Hunt is done, so begin the final bisection phase:
+      if (jhi - jlo <= 1) THEN
+        if (x == xx(n)) jlo = n - 1
+        if (x == xx(1)) jlo = 1
+        exit
+      else
+        jm = (jhi + jlo) / 2
+        if (x >= xx(jm) .eqv. ascnd) THEN
+          jlo = jm
+        else
+          jhi = jm
+        end if
+      end if
+    END DO
+
+  END SUBROUTINE hunt
+
+end module lmdz_interpolation
Index: LMDZ6/branches/Amaury_dev/libf/misc/lmdz_libmath.f90
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/misc/lmdz_libmath.f90	(revision 5116)
+++ LMDZ6/branches/Amaury_dev/libf/misc/lmdz_libmath.f90	(revision 5116)
@@ -0,0 +1,61 @@
+! Library for misc. useful math functions
+
+MODULE lmdz_libmath
+  IMPLICIT NONE; PRIVATE
+  PUBLIC ismin, ismax
+
+CONTAINS
+
+  function ismax(n, sx, incx)
+    INTEGER :: n, i, incx, ismax, ix
+    REAL :: sx((n - 1) * incx + 1), sxmax
+
+    ix = 1
+    ismax = 1
+    sxmax = sx(1)
+    do i = 1, n - 1
+      ix = ix + incx
+      IF(sx(ix)>sxmax) THEN
+        sxmax = sx(ix)
+        ismax = i + 1
+      endif
+    END DO
+  END FUNCTION ismax
+
+
+  FUNCTION ismin(n, sx, incx)
+    INTEGER :: n, i, incx, ismin, ix
+    REAL :: sx((n - 1) * incx + 1), sxmin
+    !
+    ix = 1
+    ismin = 1
+    sxmin = sx(1)
+    DO i = 1, n - 1
+      ix = ix + incx
+      IF(sx(ix)<sxmin) THEN
+        sxmin = sx(ix)
+        ismin = i + 1
+      endif
+    ENDDO
+  END FUNCTION ismin
+
+  SUBROUTINE minmax(imax, xi, zmin, zmax)
+    !
+    !  P. Le Van
+
+    INTEGER :: imax
+    REAL :: xi(imax)
+    REAL :: zmin, zmax
+    INTEGER :: i
+
+    zmin = xi(1)
+    zmax = xi(1)
+
+    DO i = 2, imax
+      zmin = MIN(zmin, xi(i))
+      zmax = MAX(zmax, xi(i))
+    ENDDO
+
+  END SUBROUTINE minmax
+
+END MODULE lmdz_libmath
Index: LMDZ6/branches/Amaury_dev/libf/misc/lmdz_libmath_pch.f90
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/misc/lmdz_libmath_pch.f90	(revision 5115)
+++ LMDZ6/branches/Amaury_dev/libf/misc/lmdz_libmath_pch.f90	(revision 5116)
@@ -489,5 +489,5 @@
     ! the points  XE.
 
-    use lmdz_assert_eq, only: assert_eq
+    use lmdz_assert_eq, ONLY: assert_eq
 
     REAL, intent(in) :: X(:) ! real array of independent variable values
@@ -572,5 +572,5 @@
     ! 2001, pages 43-47
 
-    use lmdz_assert_eq, only: assert_eq
+    use lmdz_assert_eq, ONLY: assert_eq
 
     real, intent(in) :: x(:)
@@ -638,9 +638,9 @@
 
     n = assert_eq(size(x), size(f), "pchsp_95 n")
-    if ((ibeg == 1 .or. ibeg == 2) .and. .not. present(vc_beg)) then
+    if ((ibeg == 1 .or. ibeg == 2) .and. .not. present(vc_beg)) THEN
       print *, "vc_beg required for IBEG = 1 or 2"
       stop 1
     end if
-    if ((iend == 1 .or. iend == 2) .and. .not. present(vc_end)) then
+    if ((iend == 1 .or. iend == 2) .and. .not. present(vc_end)) THEN
       print *, "vc_end required for IEND = 1 or 2"
       stop 1
Index: LMDZ6/branches/Amaury_dev/libf/misc/lmdz_xer.f90
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/misc/lmdz_xer.f90	(revision 5115)
+++ LMDZ6/branches/Amaury_dev/libf/misc/lmdz_xer.f90	(revision 5116)
@@ -748,5 +748,5 @@
     !     intrinsic function LEN is used to determine its length.  If
     !         it is zero, PREFIX is not used.  If it exceeds 16 or if
-    !     LEN(PREFIX) exceeds 16, only the first 16 characters will be
+    !     LEN(PREFIX) exceeds 16, ONLY the first 16 characters will be
     !     used.  If NPREF is positive and the length of PREFIX is less
     !     than NPREF, a copy of PREFIX extended with blanks to length
@@ -1055,4 +1055,72 @@
   END SUBROUTINE XERCNT
 
+  !DECK J4SAVE
+  FUNCTION J4SAVE(IWHICH, IVALUE, ISET)
+    IMPLICIT NONE
+    !***BEGIN PROLOGUE  J4SAVE
+    !***SUBSIDIARY
+    !***PURPOSE  Save or reCALL global variables needed by error
+    ! handling routines.
+    !***LIBRARY   SLATEC (XERROR)
+    !***TYPE      INTEGER (J4SAVE-I)
+    !***KEYWORDS  ERROR MESSAGES, ERROR NUMBER, RECALL, SAVE, XERROR
+    !***AUTHOR  Jones, R. E., (SNLA)
+    !***DESCRIPTION
+    !
+    ! Abstract
+    !    J4SAVE saves and recalls several global variables needed
+    !    by the library error handling routines.
+    !
+    ! Description of Parameters
+    !  --Input--
+    !    IWHICH - Index of item desired.
+    !            = 1 Refers to current error number.
+    !            = 2 Refers to current error control flag.
+    !            = 3 Refers to current unit number to which error
+    !                messages are to be sent.  (0 means use standard.)
+    !            = 4 Refers to the maximum number of times any
+    !                 message is to be printed (as set by XERMAX).
+    !            = 5 Refers to the total number of units to which
+    !                 each error message is to be written.
+    !            = 6 Refers to the 2nd unit for error messages
+    !            = 7 Refers to the 3rd unit for error messages
+    !            = 8 Refers to the 4th unit for error messages
+    !            = 9 Refers to the 5th unit for error messages
+    !    IVALUE - The value to be set for the IWHICH-th parameter,
+    !             if ISET is .TRUE. .
+    !    ISET   - If ISET=.TRUE., the IWHICH-th parameter will BE
+    !             given the value, IVALUE.  If ISET=.FALSE., the
+    !             IWHICH-th parameter will be unchanged, and IVALUE
+    !             is a dummy parameter.
+    !  --Output--
+    !    The (old) value of the IWHICH-th parameter will be returned
+    !    in the function value, J4SAVE.
+    !
+    !***SEE ALSO  XERMSG
+    !***REFERENCES  R. E. Jones and D. K. Kahaner, XERROR, the SLATEC
+    !             Error-handling Package, SAND82-0800, Sandia
+    !             Laboratories, 1982.
+    !***ROUTINES CALLED  (NONE)
+    !***REVISION HISTORY  (YYMMDD)
+    !   790801  DATE WRITTEN
+    !   891214  Prologue converted to Version 4.0 format.  (BAB)
+    !   900205  Minor modifications to prologue.  (WRB)
+    !   900402  Added TYPE section.  (WRB)
+    !   910411  Added KEYWORDS section.  (WRB)
+    !   920501  Reformatted the REFERENCES section.  (WRB)
+    !***END PROLOGUE  J4SAVE
+    LOGICAL :: ISET
+    INTEGER :: IPARAM(9)
+    SAVE IPARAM
+    DATA IPARAM(1), IPARAM(2), IPARAM(3), IPARAM(4)/0, 2, 0, 10/
+    DATA IPARAM(5)/1/
+    DATA IPARAM(6), IPARAM(7), IPARAM(8), IPARAM(9)/0, 0, 0, 0/
+    INTEGER :: J4SAVE, IWHICH, IVALUE
+    !***FIRST EXECUTABLE STATEMENT  J4SAVE
+    J4SAVE = IPARAM(IWHICH)
+    IF (ISET) IPARAM(IWHICH) = IVALUE
+
+  END FUNCTION J4SAVE
+
 
 END MODULE lmdz_xer
Index: LMDZ6/branches/Amaury_dev/libf/misc/minmax.f90
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/misc/minmax.f90	(revision 5115)
+++ 	(revision )
@@ -1,23 +1,0 @@
-
-! $Header$
-
- SUBROUTINE minmax(imax, xi, zmin, zmax )
-  !
-  !  P. Le Van
-
-   INTEGER :: imax
-   REAL :: xi(imax)
-   REAL :: zmin,zmax
-   INTEGER :: i
-
-   zmin = xi(1)
-   zmax = xi(1)
-
-   DO i = 2, imax
-     zmin = MIN( zmin,xi(i) )
-     zmax = MAX( zmax,xi(i) )
-   ENDDO
-
-
-END SUBROUTINE minmax
-
Index: LMDZ6/branches/Amaury_dev/libf/misc/minmax2.f90
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/misc/minmax2.f90	(revision 5115)
+++ 	(revision )
@@ -1,20 +1,0 @@
-
-! $Header$
-
- SUBROUTINE minmax2(imax, jmax, lmax, xi, zmin, zmax )
-  !
-   INTEGER :: lmax,jmax,imax
-   REAL :: xi(imax*jmax*lmax)
-   REAL :: zmin,zmax
-   INTEGER :: i
-
-   zmin = xi(1)
-   zmax = xi(1)
-
-   DO i = 2, imax*jmax*lmax
-     zmin = MIN( zmin,xi(i) )
-     zmax = MAX( zmax,xi(i) )
-   ENDDO
-
-
-END SUBROUTINE minmax2
Index: LMDZ6/branches/Amaury_dev/libf/misc/q_sat.f90
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/misc/q_sat.f90	(revision 5115)
+++ LMDZ6/branches/Amaury_dev/libf/misc/q_sat.f90	(revision 5116)
@@ -19,5 +19,5 @@
   !======================================================================
 
-  integer :: np
+  INTEGER :: np
   REAL :: temp(np),pres(np),qsat(np)
 
@@ -39,6 +39,6 @@
   PARAMETER (retv=28.9644/18.0153 - 1.0)
 
-  real :: zqsat
-  integer :: ip
+  REAL :: zqsat
+  INTEGER :: ip
 
   ! ------------------------------------------------------------------
@@ -47,6 +47,6 @@
   do ip=1,np
 
-   ! write(*,*)'kelvin,millibar=',kelvin,millibar
-   !  write(*,*)'temp,pres=',temp(ip),pres(ip)
+   ! WRITE(*,*)'kelvin,millibar=',kelvin,millibar
+   !  WRITE(*,*)'temp,pres=',temp(ip),pres(ip)
 
      IF (temp(ip) <= rtt) THEN
@@ -63,5 +63,5 @@
 
      qsat(ip)= zqsat
-   ! write(*,*)'qsat=',qsat(ip)
+   ! WRITE(*,*)'qsat=',qsat(ip)
 
   enddo
Index: LMDZ6/branches/Amaury_dev/libf/misc/regr1_step_av_m.F90
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/misc/regr1_step_av_m.F90	(revision 5115)
+++ LMDZ6/branches/Amaury_dev/libf/misc/regr1_step_av_m.F90	(revision 5116)
@@ -30,7 +30,7 @@
     ! "vs" has rank 1.
 
-    use lmdz_assert_eq, only: assert_eq
-    use lmdz_assert, only: assert
-    use interpolation, only: locate
+    use lmdz_assert_eq, ONLY: assert_eq
+    use lmdz_assert, ONLY: assert
+    use lmdz_interpolation, ONLY: locate
 
     real, intent(in):: vs(:) ! values of steps on the source grid
@@ -81,5 +81,5 @@
     END DO
 
-  end function regr11_step_av
+  END FUNCTION regr11_step_av
 
   !********************************************
@@ -89,7 +89,7 @@
     ! "vs" has rank 2.
 
-    use lmdz_assert_eq, only: assert_eq
-    use lmdz_assert, only: assert
-    use interpolation, only: locate
+    use lmdz_assert_eq, ONLY: assert_eq
+    use lmdz_assert, ONLY: assert
+    use lmdz_interpolation, ONLY: locate
 
     real, intent(in):: vs(:, :) ! values of steps on the source grid
@@ -141,5 +141,5 @@
     END DO
 
-  end function regr12_step_av
+  END FUNCTION regr12_step_av
 
   !********************************************
@@ -149,7 +149,7 @@
     ! "vs" has rank 3.
 
-    use lmdz_assert_eq, only: assert_eq
-    use lmdz_assert, only: assert
-    use interpolation, only: locate
+    use lmdz_assert_eq, ONLY: assert_eq
+    use lmdz_assert, ONLY: assert
+    use lmdz_interpolation, ONLY: locate
 
     real, intent(in):: vs(:, :, :) ! values of steps on the source grid
@@ -202,5 +202,5 @@
     END DO
 
-  end function regr13_step_av
+  END FUNCTION regr13_step_av
 
   !********************************************
@@ -210,7 +210,7 @@
     ! "vs" has rank 4.
 
-    use lmdz_assert_eq, only: assert_eq
-    use lmdz_assert, only: assert
-    use interpolation, only: locate
+    use lmdz_assert_eq, ONLY: assert_eq
+    use lmdz_assert, ONLY: assert
+    use lmdz_interpolation, ONLY: locate
 
     real, intent(in):: vs(:, :, :, :) ! values of steps on the source grid
@@ -264,5 +264,5 @@
     END DO
 
-  end function regr14_step_av
+  END FUNCTION regr14_step_av
 
 end module regr1_step_av_m
Index: LMDZ6/branches/Amaury_dev/libf/misc/regr_conserv_m.F90
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/misc/regr_conserv_m.F90	(revision 5115)
+++ LMDZ6/branches/Amaury_dev/libf/misc/regr_conserv_m.F90	(revision 5116)
@@ -3,5 +3,5 @@
   USE lmdz_assert_eq,   ONLY: assert_eq
   USE lmdz_assert,      ONLY: assert
-  USE interpolation, ONLY: locate
+  use lmdz_interpolation, ONLY: locate
 
   IMPLICIT NONE
Index: LMDZ6/branches/Amaury_dev/libf/misc/regr_lint_m.F90
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/misc/regr_lint_m.F90	(revision 5115)
+++ LMDZ6/branches/Amaury_dev/libf/misc/regr_lint_m.F90	(revision 5116)
@@ -3,5 +3,5 @@
   USE lmdz_assert_eq,   ONLY: assert_eq
   USE lmdz_assert,      ONLY: assert
-  USE interpolation, ONLY: hunt
+  use lmdz_interpolation, ONLY: hunt
 
   IMPLICIT NONE
Index: LMDZ6/branches/Amaury_dev/libf/misc/vampir.F90
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/misc/vampir.F90	(revision 5115)
+++ LMDZ6/branches/Amaury_dev/libf/misc/vampir.F90	(revision 5116)
@@ -20,5 +20,5 @@
 #ifdef USE_VT
     include 'VT.inc'
-    integer :: ierr
+    INTEGER :: ierr
     
     CALL VTSYMDEF(VTcaldyn,"caldyn","caldyn",ierr)
@@ -33,5 +33,5 @@
 #ifdef USE_MPE
     include 'mpe_logf.h' 
-    integer :: ierr,i
+    INTEGER :: ierr,i
     
     DO i=1,nb_inst
@@ -54,5 +54,5 @@
 #ifdef USE_VT    
     include 'VT.inc'
-    integer :: ierr
+    INTEGER :: ierr
     
     CALL VTBEGIN(number,ierr)
@@ -60,5 +60,5 @@
 #ifdef USE_MPE
     include 'mpe_logf.h' 
-    integer :: ierr,i
+    INTEGER :: ierr,i
     ierr = MPE_Log_event( MPE_begin(number), 0, '' )
 #endif
@@ -71,5 +71,5 @@
 #ifdef USE_VT    
     include 'VT.inc'
-    integer :: ierr
+    INTEGER :: ierr
    
     CALL VTEND(number,ierr)
@@ -78,5 +78,5 @@
 #ifdef USE_MPE
     include 'mpe_logf.h' 
-    integer :: ierr,i
+    INTEGER :: ierr,i
     ierr = MPE_Log_event( MPE_end(number), 0, '' )
 #endif
Index: LMDZ6/branches/Amaury_dev/libf/misc/write_field.F90
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/misc/write_field.F90	(revision 5115)
+++ LMDZ6/branches/Amaury_dev/libf/misc/write_field.F90	(revision 5116)
@@ -12,5 +12,5 @@
   integer, dimension(MaxWriteField), save :: FieldVarId
   integer, dimension(MaxWriteField), save :: FieldIndex
-  character(len = 255), dimension(MaxWriteField) :: FieldName
+  CHARACTER(LEN = 255), dimension(MaxWriteField) :: FieldName
 
   integer, save :: NbField = 0
@@ -23,9 +23,9 @@
   function GetFieldIndex(name)
     IMPLICIT NONE
-    integer :: GetFieldindex
-    character(len = *) :: name
-
-    character(len = 255) :: TrueName
-    integer :: i
+    INTEGER :: GetFieldindex
+    CHARACTER(LEN = *) :: name
+
+    CHARACTER(LEN = 255) :: TrueName
+    INTEGER :: i
 
     TrueName = TRIM(ADJUSTL(name))
@@ -33,14 +33,14 @@
     GetFieldIndex = -1
     do i = 1, NbField
-      if (TrueName==FieldName(i)) then
+      if (TrueName==FieldName(i)) THEN
         GetFieldIndex = i
         exit
       endif
     enddo
-  end function GetFieldIndex
+  END FUNCTION GetFieldIndex
 
   subroutine WriteField3d(name, Field)
     IMPLICIT NONE
-    character(len = *) :: name
+    CHARACTER(LEN = *) :: name
     real, dimension(:, :, :) :: Field
     integer, dimension(3) :: Dim
@@ -49,9 +49,9 @@
     CALL WriteField_gen(name, Field, Dim(1), Dim(2), Dim(3))
 
-  end subroutine WriteField3d
+  END SUBROUTINE WriteField3d
 
   subroutine WriteField2d(name, Field)
     IMPLICIT NONE
-    character(len = *) :: name
+    CHARACTER(LEN = *) :: name
     real, dimension(:, :) :: Field
     integer, dimension(2) :: Dim
@@ -60,9 +60,9 @@
     CALL WriteField_gen(name, Field, Dim(1), Dim(2), 1)
 
-  end subroutine WriteField2d
+  END SUBROUTINE WriteField2d
 
   subroutine WriteField1d(name, Field)
     IMPLICIT NONE
-    character(len = *) :: name
+    CHARACTER(LEN = *) :: name
     real, dimension(:) :: Field
     integer, dimension(1) :: Dim
@@ -71,19 +71,19 @@
     CALL WriteField_gen(name, Field, Dim(1), 1, 1)
 
-  end subroutine WriteField1d
+  END SUBROUTINE WriteField1d
 
   subroutine WriteField_gen(name, Field, dimx, dimy, dimz)
     IMPLICIT NONE
-    character(len = *) :: name
-    integer :: dimx, dimy, dimz
+    CHARACTER(LEN = *) :: name
+    INTEGER :: dimx, dimy, dimz
     real, dimension(dimx, dimy, dimz) :: Field
     integer, dimension(dimx * dimy * dimz) :: ndex
-    integer :: status
-    integer :: index
-    integer :: start(4)
-    integer :: count(4)
+    INTEGER :: status
+    INTEGER :: index
+    INTEGER :: start(4)
+    INTEGER :: count(4)
 
     Index = GetFieldIndex(name)
-    if (Index==-1) then
+    if (Index==-1) THEN
       CALL CreateNewField(name, dimx, dimy, dimz)
       Index = GetFieldIndex(name)
@@ -105,12 +105,12 @@
     status = nf90_sync(FieldId(Index))
 
-  end subroutine WriteField_gen
+  END SUBROUTINE WriteField_gen
 
   subroutine CreateNewField(name, dimx, dimy, dimz)
     IMPLICIT NONE
-    character(len = *) :: name
-    integer :: dimx, dimy, dimz
-    integer :: TabDim(4)
-    integer :: status
+    CHARACTER(LEN = *) :: name
+    INTEGER :: dimx, dimy, dimz
+    INTEGER :: TabDim(4)
+    INTEGER :: status
 
     NbField = NbField + 1
@@ -126,5 +126,5 @@
     status = nf90_enddef(FieldId(NbField))
 
-  end subroutine CreateNewField
+  END SUBROUTINE CreateNewField
 
   subroutine write_field1D(name, Field)
@@ -132,16 +132,16 @@
 
     integer, parameter :: MaxDim = 1
-    character(len = *) :: name
+    CHARACTER(LEN = *) :: name
     real, dimension(:) :: Field
     real, dimension(:), allocatable :: New_Field
-    character(len = 20) :: str
+    CHARACTER(LEN = 20) :: str
     integer, dimension(MaxDim) :: Dim
-    integer :: i, nb
+    INTEGER :: i, nb
     integer, parameter :: id = 10
     integer, parameter :: NbCol = 4
-    integer :: ColumnSize
-    integer :: pos
-    character(len = 255) :: form
-    character(len = 255) :: MaxLen
+    INTEGER :: ColumnSize
+    INTEGER :: pos
+    CHARACTER(LEN = 255) :: form
+    CHARACTER(LEN = 255) :: MaxLen
 
     open(unit = id, file = name // '.field', form = 'formatted', status = 'replace')
@@ -155,5 +155,5 @@
       nb = nb + 1
 
-      if (MOD(nb, NbCol)==0) then
+      if (MOD(nb, NbCol)==0) THEN
         form = '(t' // trim(int2str(pos)) // ',i' // trim(MaxLen) // '," ---> ",g22.16,/)'
         Pos = 2
@@ -167,5 +167,5 @@
     close(id)
 
-  end subroutine write_field1D
+  END SUBROUTINE write_field1D
 
   subroutine write_field2D(name, Field)
@@ -173,16 +173,16 @@
 
     integer, parameter :: MaxDim = 2
-    character(len = *) :: name
+    CHARACTER(LEN = *) :: name
     real, dimension(:, :) :: Field
     real, dimension(:, :), allocatable :: New_Field
-    character(len = 20) :: str
+    CHARACTER(LEN = 20) :: str
     integer, dimension(MaxDim) :: Dim
-    integer :: i, j, nb
+    INTEGER :: i, j, nb
     integer, parameter :: id = 10
     integer, parameter :: NbCol = 4
-    integer :: ColumnSize
-    integer :: pos, offset
-    character(len = 255) :: form
-    character(len = 255) :: spacing
+    INTEGER :: ColumnSize
+    INTEGER :: pos, offset
+    CHARACTER(LEN = 255) :: form
+    CHARACTER(LEN = 255) :: spacing
 
     open(unit = id, file = name // '.field', form = 'formatted', status = 'replace')
@@ -201,5 +201,5 @@
         nb = nb + 1
 
-        if (MOD(nb, NbCol)==0) then
+        if (MOD(nb, NbCol)==0) THEN
           form = '(t' // trim(int2str(pos)) // &
                   ',"(' // trim(int2str(j)) // ','          &
@@ -218,5 +218,5 @@
         write (id, form, advance = 'no') Field(j, i)
       enddo
-      if (MOD(nb, NbCol)==0) then
+      if (MOD(nb, NbCol)==0) THEN
         write (id, spacing)
       else
@@ -226,5 +226,5 @@
     enddo
 
-  end subroutine write_field2D
+  END SUBROUTINE write_field2D
 
   subroutine write_field3D(name, Field)
@@ -232,15 +232,15 @@
 
     integer, parameter :: MaxDim = 3
-    character(len = *) :: name
+    CHARACTER(LEN = *) :: name
     real, dimension(:, :, :) :: Field
     real, dimension(:, :, :), allocatable :: New_Field
     integer, dimension(MaxDim) :: Dim
-    integer :: i, j, k, nb
+    INTEGER :: i, j, k, nb
     integer, parameter :: id = 10
     integer, parameter :: NbCol = 4
-    integer :: ColumnSize
-    integer :: pos, offset
-    character(len = 255) :: form
-    character(len = 255) :: spacing
+    INTEGER :: ColumnSize
+    INTEGER :: pos, offset
+    CHARACTER(LEN = 255) :: form
+    CHARACTER(LEN = 255) :: spacing
 
     open(unit = id, file = name // '.field', form = 'formatted', status = 'replace')
@@ -264,5 +264,5 @@
           nb = nb + 1
 
-          if (MOD(nb, NbCol)==0) then
+          if (MOD(nb, NbCol)==0) THEN
             form = '(t' // trim(int2str(pos)) // &
                     ',"(' // trim(int2str(k)) // ','          &
@@ -284,5 +284,5 @@
           write (id, form, advance = 'no') Field(k, j, i)
         enddo
-        if (MOD(nb, NbCol)==0) then
+        if (MOD(nb, NbCol)==0) THEN
           write (id, spacing)
         else
@@ -296,5 +296,5 @@
     close(id)
 
-  end subroutine write_field3D
+  END SUBROUTINE write_field3D
 
 end module write_field
Index: LMDZ6/branches/Amaury_dev/libf/misc/wxios.F90
===================================================================
--- LMDZ6/branches/Amaury_dev/libf/misc/wxios.F90	(revision 5115)
+++ LMDZ6/branches/Amaury_dev/libf/misc/wxios.F90	(revision 5116)
@@ -359,10 +359,10 @@
     !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     SUBROUTINE wxios_domain_param(dom_id)
-       USE dimphy, only: klon
+       USE dimphy, ONLY: klon
        USE lmdz_phys_transfert_para, ONLY: gather, bcast
-       USE lmdz_phys_para, only: jj_nb, jj_begin, jj_end, ii_begin, ii_end, &
+       USE lmdz_phys_para, ONLY: jj_nb, jj_begin, jj_end, ii_begin, ii_end, &
                                      mpi_size, mpi_rank, klon_mpi, &
                                      is_sequential, is_south_pole_dyn
-       USE lmdz_grid_phy, only: nbp_lon, nbp_lat, klon_glo
+       USE lmdz_grid_phy, ONLY: nbp_lon, nbp_lat, klon_glo
        USE lmdz_print_control, ONLY: prt_level, lunout
        USE lmdz_geometry
@@ -390,5 +390,5 @@
         io_lat(1)=rlat_glo(1)
         io_lat(nbp_lat)=rlat_glo(klon_glo)
-        IF ((nbp_lon*nbp_lat) > 1) then
+        IF ((nbp_lon*nbp_lat) > 1) THEN
           DO i=2,nbp_lat-1
             io_lat(i)=rlat_glo(2+(i-2)*nbp_lon)
@@ -532,11 +532,11 @@
         
         ! Ehouarn: New way to declare axis, without axis_group:
-        if (PRESENT(positif) .AND. PRESENT(bnds)) then
+        if (PRESENT(positif) .AND. PRESENT(bnds)) THEN
           CALL xios_set_axis_attr(trim(axis_id),n_glo=axis_size,value=axis_value, &
                                   positive=positif, bounds=bnds)
-        else if (PRESENT(positif)) then
+        else if (PRESENT(positif)) THEN
           CALL xios_set_axis_attr(trim(axis_id),n_glo=axis_size,value=axis_value, &
                                   positive=positif)
-        else if (PRESENT(bnds)) then
+        else if (PRESENT(bnds)) THEN
           CALL xios_set_axis_attr(trim(axis_id),n_glo=axis_size,value=axis_value, &
                                   bounds=bnds)
@@ -605,5 +605,5 @@
     !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
     SUBROUTINE wxios_add_field(fieldname, fieldgroup, fieldlongname, fieldunit)
-        USE netcdf, only: nf90_fill_real
+        USE netcdf, ONLY: nf90_fill_real
 
         IMPLICIT NONE
