Index: /LMDZ6/branches/Amaury_dev/libf/dyn3d_common/fxy.f90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d_common/fxy.f90	(revision 5107)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3d_common/fxy.f90	(revision 5108)
@@ -1,11 +1,11 @@
-
 ! $Id$
 
-SUBROUTINE fxy(rlatu,yprimu,rlatv,yprimv,rlatu1,yprimu1, &
-        rlatu2,yprimu2, &
-        rlonu,xprimu,rlonv,xprimv,rlonm025,xprimm025,rlonp025,xprimp025)
+SUBROUTINE fxy(rlatu, yprimu, rlatv, yprimv, rlatu1, yprimu1, &
+        rlatu2, yprimu2, &
+        rlonu, xprimu, rlonv, xprimv, rlonm025, xprimm025, rlonp025, xprimp025)
 
   USE comconst_mod, ONLY: pi
-  USE serre_mod, ONLY: pxo,pyo,alphax,alphay,transx,transy
+  USE serre_mod, ONLY: pxo, pyo, alphax, alphay, transx, transy
+  USE lmdz_fxy, ONLY: fxy_new
 
   IMPLICIT NONE
@@ -20,48 +20,47 @@
   include "paramet.h"
 
-   INTEGER :: i,j
+  INTEGER :: i, j
 
-   REAL :: rlatu(jjp1), yprimu(jjp1),rlatv(jjm), yprimv(jjm), &
-         rlatu1(jjm), yprimu1(jjm), rlatu2(jjm), yprimu2(jjm)
-   REAL :: rlonu(iip1),xprimu(iip1),rlonv(iip1),xprimv(iip1), &
-         rlonm025(iip1),xprimm025(iip1), rlonp025(iip1),xprimp025(iip1)
+  REAL :: rlatu(jjp1), yprimu(jjp1), rlatv(jjm), yprimv(jjm), &
+          rlatu1(jjm), yprimu1(jjm), rlatu2(jjm), yprimu2(jjm)
+  REAL :: rlonu(iip1), xprimu(iip1), rlonv(iip1), xprimv(iip1), &
+          rlonm025(iip1), xprimm025(iip1), rlonp025(iip1), xprimp025(iip1)
+  REAL :: ripx, fx, fxprim, fy, fyprim, ri, rj, bigy
 
-  INCLUDE "fxy_new.h"
-
+  CALL fxy_new(ripx, fx, fxprim, fy, fyprim, ri, rj, bigy)
 
   !    ......  calcul  des  latitudes  et de y'   .....
   !
-   DO j = 1, jjm + 1
-      rlatu(j) = fy    ( REAL( j )        )
-     yprimu(j) = fyprim( REAL( j )        )
-   ENDDO
+  DO j = 1, jjm + 1
+    rlatu(j) = fy    (REAL(j))
+    yprimu(j) = fyprim(REAL(j))
+  ENDDO
 
+  DO j = 1, jjm
 
-   DO j = 1, jjm
+    rlatv(j) = fy    (REAL(j) + 0.5)
+    rlatu1(j) = fy    (REAL(j) + 0.25)
+    rlatu2(j) = fy    (REAL(j) + 0.75)
 
-     rlatv(j)  = fy    ( REAL( j ) + 0.5  )
-     rlatu1(j) = fy    ( REAL( j ) + 0.25 )
-     rlatu2(j) = fy    ( REAL( j ) + 0.75 )
+    yprimv(j) = fyprim(REAL(j) + 0.5)
+    yprimu1(j) = fyprim(REAL(j) + 0.25)
+    yprimu2(j) = fyprim(REAL(j) + 0.75)
 
-    yprimv(j)  = fyprim( REAL( j ) + 0.5  )
-    yprimu1(j) = fyprim( REAL( j ) + 0.25 )
-    yprimu2(j) = fyprim( REAL( j ) + 0.75 )
-
-   ENDDO
+  ENDDO
 
   !
   ! .....  calcul   des  longitudes et de  x'   .....
   !
-   DO i = 1, iim + 1
-       rlonv(i)     = fx    (   REAL( i )          )
-       rlonu(i)     = fx    (   REAL( i ) + 0.5    )
-    rlonm025(i)     = fx    (   REAL( i ) - 0.25  )
-    rlonp025(i)     = fx    (   REAL( i ) + 0.25  )
+  DO i = 1, iim + 1
+    rlonv(i) = fx    (REAL(i))
+    rlonu(i) = fx    (REAL(i) + 0.5)
+    rlonm025(i) = fx    (REAL(i) - 0.25)
+    rlonp025(i) = fx    (REAL(i) + 0.25)
 
-     xprimv  (i)    = fxprim (  REAL( i )          )
-     xprimu  (i)    = fxprim (  REAL( i ) + 0.5    )
-    xprimm025(i)    = fxprim (  REAL( i ) - 0.25   )
-    xprimp025(i)    = fxprim (  REAL( i ) + 0.25   )
-   ENDDO
+    xprimv  (i) = fxprim (REAL(i))
+    xprimu  (i) = fxprim (REAL(i) + 0.5)
+    xprimm025(i) = fxprim (REAL(i) - 0.25)
+    xprimp025(i) = fxprim (REAL(i) + 0.25)
+  ENDDO
 
   !
Index: /LMDZ6/branches/Amaury_dev/libf/dyn3d_common/fxysinus.f90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/dyn3d_common/fxysinus.f90	(revision 5107)
+++ /LMDZ6/branches/Amaury_dev/libf/dyn3d_common/fxysinus.f90	(revision 5108)
@@ -1,11 +1,10 @@
-
 ! $Id$
 
-SUBROUTINE fxysinus(rlatu,yprimu,rlatv,yprimv,rlatu1,yprimu1, &
-        rlatu2,yprimu2, &
-        rlonu,xprimu,rlonv,xprimv,rlonm025,xprimm025,rlonp025,xprimp025)
-
+SUBROUTINE fxysinus(rlatu, yprimu, rlatv, yprimv, rlatu1, yprimu1, &
+        rlatu2, yprimu2, &
+        rlonu, xprimu, rlonv, xprimv, rlonm025, xprimm025, rlonp025, xprimp025)
 
   USE comconst_mod, ONLY: pi
+  USE lmdz_fxy, ONLY: fxy_sin
   IMPLICIT NONE
   !
@@ -19,51 +18,51 @@
   INCLUDE "paramet.h"
 
-   INTEGER :: i,j
+  INTEGER :: i, j
 
-   REAL :: rlatu(jjp1), yprimu(jjp1),rlatv(jjm), yprimv(jjm), &
-         rlatu1(jjm), yprimu1(jjm), rlatu2(jjm), yprimu2(jjm)
-   REAL :: rlonu(iip1),xprimu(iip1),rlonv(iip1),xprimv(iip1), &
-         rlonm025(iip1),xprimm025(iip1), rlonp025(iip1),xprimp025(iip1)
+  REAL :: rlatu(jjp1), yprimu(jjp1), rlatv(jjm), yprimv(jjm), &
+          rlatu1(jjm), yprimu1(jjm), rlatu2(jjm), yprimu2(jjm)
+  REAL :: rlonu(iip1), xprimu(iip1), rlonv(iip1), xprimv(iip1), &
+          rlonm025(iip1), xprimm025(iip1), rlonp025(iip1), xprimp025(iip1)
+  REAL :: fy, fx, fxprim, fyprim, ri, rj
 
-  INCLUDE "fxy_sin.h"
+  CALL fxy_sin(fy, fx, fxprim, fyprim, ri, rj)
 
 
   !    ......  calcul  des  latitudes  et de y'   .....
   !
-   DO j = 1, jjm + 1
-      rlatu(j) = fy    ( REAL( j )        )
-     yprimu(j) = fyprim( REAL( j )        )
-   ENDDO
+  DO j = 1, jjm + 1
+    rlatu(j) = fy    (REAL(j))
+    yprimu(j) = fyprim(REAL(j))
+  ENDDO
 
+  DO j = 1, jjm
 
-   DO j = 1, jjm
+    rlatv(j) = fy    (REAL(j) + 0.5)
+    rlatu1(j) = fy    (REAL(j) + 0.25)
+    rlatu2(j) = fy    (REAL(j) + 0.75)
 
-     rlatv(j)  = fy    ( REAL( j ) + 0.5  )
-     rlatu1(j) = fy    ( REAL( j ) + 0.25 )
-     rlatu2(j) = fy    ( REAL( j ) + 0.75 )
+    yprimv(j) = fyprim(REAL(j) + 0.5)
+    yprimu1(j) = fyprim(REAL(j) + 0.25)
+    yprimu2(j) = fyprim(REAL(j) + 0.75)
 
-    yprimv(j)  = fyprim( REAL( j ) + 0.5  )
-    yprimu1(j) = fyprim( REAL( j ) + 0.25 )
-    yprimu2(j) = fyprim( REAL( j ) + 0.75 )
-
-   ENDDO
+  ENDDO
 
   !
   ! .....  calcul   des  longitudes et de  x'   .....
   !
-   DO i = 1, iim + 1
-       rlonv(i)     = fx    (   REAL( i )          )
-       rlonu(i)     = fx    (   REAL( i ) + 0.5    )
-    rlonm025(i)     = fx    (   REAL( i ) - 0.25  )
-    rlonp025(i)     = fx    (   REAL( i ) + 0.25  )
+  DO i = 1, iim + 1
+    rlonv(i) = fx    (REAL(i))
+    rlonu(i) = fx    (REAL(i) + 0.5)
+    rlonm025(i) = fx    (REAL(i) - 0.25)
+    rlonp025(i) = fx    (REAL(i) + 0.25)
 
-     xprimv  (i)    = fxprim (  REAL( i )          )
-     xprimu  (i)    = fxprim (  REAL( i ) + 0.5    )
-    xprimm025(i)    = fxprim (  REAL( i ) - 0.25   )
-    xprimp025(i)    = fxprim (  REAL( i ) + 0.25   )
-   ENDDO
+    xprimv  (i) = fxprim (REAL(i))
+    xprimu  (i) = fxprim (REAL(i) + 0.5)
+    xprimm025(i) = fxprim (REAL(i) - 0.25)
+    xprimp025(i) = fxprim (REAL(i) + 0.25)
+  ENDDO
 
   !
-   RETURN
+  RETURN
 END SUBROUTINE fxysinus
 
Index: DZ6/branches/Amaury_dev/libf/grid/fxy_new.h
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/grid/fxy_new.h	(revision 5107)
+++ 	(revision )
@@ -1,27 +1,0 @@
-
-! $Header$
-
-!--------------------------------------------------------------
-   REAL :: ripx
-   REAL :: fx,fxprim,fy,fyprim,ri,rj,bigy
-!
-!....stretching in x...
-!
-  ripx(  ri )= (ri-1.0) *2.*pi/REAL(iim)
-  fx  (  ri )= ripx(ri) + transx  + &
-        alphax * SIN( ripx(ri)+transx-pxo ) - pi
-  fxprim(ri) = 2.*pi/REAL(iim)  * &
-        ( 1.+ alphax * COS( ripx(ri)+transx-pxo ) )
-
-!....stretching in y...
-!
-  bigy(rj)   = 2.* (REAL(jjp1)-rj ) *pi/jjm
-  fy(rj)     =  ( bigy(rj) + transy  + &
-        alphay * SIN( bigy(rj)+transy-pyo ) ) /2.  - pi/2.
-  fyprim(rj) = ( pi/jjm ) * ( 1.+ &
-        alphay * COS( bigy(rj)+transy-pyo ) )
-
-  ! fy(rj)= pyo-pisjjm*(rj-transy)+coefalpha*SIN(depisjm*(rj-
-! *  transy ))
-!   fyprim(rj)= pisjjm-pisjjm*coefy2* COS(depisjm*(rj-transy))
-!--------------------------------------------------------------
Index: DZ6/branches/Amaury_dev/libf/grid/fxy_reg.h
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/grid/fxy_reg.h	(revision 5107)
+++ 	(revision )
@@ -1,45 +1,0 @@
-
-! $Header$
-
-!-----------------------------------------------------------------------
-! INCLUDE 'fxyprim.h'
-!
-!    ................................................................
-!    ................  Fonctions in line  ...........................
-!    ................................................................
-!
-REAL :: fy, fx, fxprim, fyprim
-REAL :: ri, rj
-!
-!
-fy    ( rj ) =    pi/REAL(jjm) * ( 0.5 * REAL(jjm) +  1. - rj  )
-fyprim( rj ) =    pi/REAL(jjm)
-
-! fy(rj)=ASIN(1.+2.*((1.-rj)/REAL(jjm)))
-! fyprim(rj)=1./SQRT((rj-1.)*(jjm+1.-rj))
-
-fx    ( ri ) = 2.*pi/REAL(iim) * ( ri - 0.5*  REAL(iim) - 1. )
-! fx    ( ri ) = 2.*pi/REAL(iim) * ( ri - 0.5* ( REAL(iim) + 1.) )
-fxprim( ri ) = 2.*pi/REAL(iim)
-!
-!
-!    La valeur de pi est passee par le common/const/ou /const2/ .
-!    Sinon, il faut la calculer avant d'appeler ces fonctions .
-!
-!   ----------------------------------------------------------------
-! Fonctions a changer eventuellement, selon x(x) et y(y) choisis .
-!   -----------------------------------------------------------------
-!
-!    .....  ici, on a l'application particuliere suivante   ........
-!
-!            **************************************
-!            **     x = 2. * pi/iim *  X         **
-!            **     y =      pi/jjm *  Y         **
-!            **************************************
-!
-!   ..................................................................
-!   ..................................................................
-!
-!
-!
-!-----------------------------------------------------------------------
Index: DZ6/branches/Amaury_dev/libf/grid/fxy_sin.h
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/grid/fxy_sin.h	(revision 5107)
+++ 	(revision )
@@ -1,42 +1,0 @@
-
-! $Header$
-
-!-----------------------------------------------------------------------
-! INCLUDE 'fxyprim.h'
-!
-!    ................................................................
-!    ................  Fonctions in line  ...........................
-!    ................................................................
-!
-REAL :: fy, fx, fxprim, fyprim
-REAL :: ri, rj
-!
-!
-fy(rj)=ASIN(1.+2.*((1.-rj)/REAL(jjm)))
-fyprim(rj)=1./SQRT((rj-1.)*(jjm+1.-rj))
-
-fx    ( ri ) = 2.*pi/REAL(iim) * ( ri - 0.5*  REAL(iim) - 1. )
-! fx    ( ri ) = 2.*pi/REAL(iim) * ( ri - 0.5* ( REAL(iim) + 1.) )
-fxprim( ri ) = 2.*pi/REAL(iim)
-!
-!
-!    La valeur de pi est passee par le common/const/ou /const2/ .
-!    Sinon, il faut la calculer avant d'appeler ces fonctions .
-!
-!   ----------------------------------------------------------------
-! Fonctions a changer eventuellement, selon x(x) et y(y) choisis .
-!   -----------------------------------------------------------------
-!
-!    .....  ici, on a l'application particuliere suivante   ........
-!
-!            **************************************
-!            **     x = 2. * pi/iim *  X         **
-!            **     y =      pi/jjm *  Y         **
-!            **************************************
-!
-!   ..................................................................
-!   ..................................................................
-!
-!
-!
-!-----------------------------------------------------------------------
Index: DZ6/branches/Amaury_dev/libf/grid/fxyprim.h
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/grid/fxyprim.h	(revision 5107)
+++ 	(revision )
@@ -1,45 +1,0 @@
-
-! $Header$
-
-!-----------------------------------------------------------------------
-! INCLUDE 'fxyprim.h'
-!
-!    ................................................................
-!    ................  Fonctions in line  ...........................
-!    ................................................................
-!
-REAL :: fy, fx, fxprim, fyprim
-REAL :: ri, rj
-!
-!
-fy    ( rj ) =    pi/REAL(jjm) * ( 0.5 * REAL(jjm) +  1. - rj  )
-fyprim( rj ) =    pi/REAL(jjm)
-
-! fy(rj)=ASIN(1.+2.*((1.-rj)/REAL(jjm)))
-! fyprim(rj)=1./SQRT((rj-1.)*(jjm+1.-rj))
-
-fx    ( ri ) = 2.*pi/REAL(iim) * ( ri - 0.5*  REAL(iim) - 1. )
-! fx    ( ri ) = 2.*pi/REAL(iim) * ( ri - 0.5* ( REAL(iim) + 1.) )
-fxprim( ri ) = 2.*pi/REAL(iim)
-!
-!
-!    La valeur de pi est passee par le common/const/ou /const2/ .
-!    Sinon, il faut la calculer avant d'appeler ces fonctions .
-!
-!   ----------------------------------------------------------------
-! Fonctions a changer eventuellement, selon x(x) et y(y) choisis .
-!   -----------------------------------------------------------------
-!
-!    .....  ici, on a l'application particuliere suivante   ........
-!
-!            **************************************
-!            **     x = 2. * pi/iim *  X         **
-!            **     y =      pi/jjm *  Y         **
-!            **************************************
-!
-!   ..................................................................
-!   ..................................................................
-!
-!
-!
-!-----------------------------------------------------------------------
Index: /LMDZ6/branches/Amaury_dev/libf/grid/lmdz_fxy.f90
===================================================================
--- /LMDZ6/branches/Amaury_dev/libf/grid/lmdz_fxy.f90	(revision 5108)
+++ /LMDZ6/branches/Amaury_dev/libf/grid/lmdz_fxy.f90	(revision 5108)
@@ -0,0 +1,136 @@
+! This module replaces grid/fxy*.h
+
+MODULE lmdz_fxy
+  IMPLICIT NONE; PRIVATE
+  PUBLIC fxy_new, fxy_reg, fxy_sin, fxy_prim
+CONTAINS
+  SUBROUTINE fxy_new(ripx, fx, fxprim, fy, fyprim, ri, rj, bigy)
+    INCLUDE "dimensions.h"
+    REAL :: ripx, fx, fxprim, fy, fyprim, ri, rj, bigy
+
+    !....stretching in x...
+    ripx(ri) = (ri - 1.0) * 2. * pi / REAL(iim)
+    fx  (ri) = ripx(ri) + transx + &
+            alphax * SIN(ripx(ri) + transx - pxo) - pi
+    fxprim(ri) = 2. * pi / REAL(iim) * &
+            (1. + alphax * COS(ripx(ri) + transx - pxo))
+
+    !....stretching in y...
+    bigy(rj) = 2. * (REAL(jjp1) - rj) * pi / jjm
+    fy(rj) = (bigy(rj) + transy + &
+            alphay * SIN(bigy(rj) + transy - pyo)) / 2. - pi / 2.
+    fyprim(rj) = (pi / jjm) * (1. + &
+            alphay * COS(bigy(rj) + transy - pyo))
+
+    ! fy(rj)= pyo-pisjjm*(rj-transy)+coefalpha*SIN(depisjm*(rj-
+    ! *  transy ))
+    !   fyprim(rj)= pisjjm-pisjjm*coefy2* COS(depisjm*(rj-transy))
+    !--------------------------------------------------------------
+  END SUBROUTINE fxy_new
+
+  SUBROUTINE fxy_reg(fy, fx, fxprim, fyprim, ri, rj)
+    INCLUDE "dimensions.h"
+    REAL :: fy, fx, fxprim, fyprim, ri, rj
+
+    fy    (rj) = pi / REAL(jjm) * (0.5 * REAL(jjm) + 1. - rj)
+    fyprim(rj) = pi / REAL(jjm)
+
+    ! fy(rj)=ASIN(1.+2.*((1.-rj)/REAL(jjm)))
+    ! fyprim(rj)=1./SQRT((rj-1.)*(jjm+1.-rj))
+
+    fx    (ri) = 2. * pi / REAL(iim) * (ri - 0.5 * REAL(iim) - 1.)
+    ! fx    ( ri ) = 2.*pi/REAL(iim) * ( ri - 0.5* ( REAL(iim) + 1.) )
+    fxprim(ri) = 2. * pi / REAL(iim)
+    !
+    !    La valeur de pi est passee par le common/const/ou /const2/ .
+    !    Sinon, il faut la calculer avant d'appeler ces fonctions .
+    !
+    !   ----------------------------------------------------------------
+    ! Fonctions a changer eventuellement, selon x(x) et y(y) choisis .
+    !   -----------------------------------------------------------------
+    !
+    !    .....  ici, on a l'application particuliere suivante   ........
+    !
+    !            **************************************
+    !            **     x = 2. * pi/iim *  X         **
+    !            **     y =      pi/jjm *  Y         **
+    !            **************************************
+    !
+    !   ..................................................................
+    !   ..................................................................
+    !
+    !
+    !
+    !-----------------------------------------------------------------------
+
+  END SUBROUTINE fxy_reg
+
+  SUBROUTINE fxy_sin(fy, fx, fxprim, fyprim, ri, rj)
+    REAL :: fy, fx, fxprim, fyprim, ri, rj
+
+    fy(rj) = ASIN(1. + 2. * ((1. - rj) / REAL(jjm)))
+    fyprim(rj) = 1. / SQRT((rj - 1.) * (jjm + 1. - rj))
+
+    fx    (ri) = 2. * pi / REAL(iim) * (ri - 0.5 * REAL(iim) - 1.)
+    ! fx    ( ri ) = 2.*pi/REAL(iim) * ( ri - 0.5* ( REAL(iim) + 1.) )
+    fxprim(ri) = 2. * pi / REAL(iim)
+    !
+    !
+    !    La valeur de pi est passee par le common/const/ou /const2/ .
+    !    Sinon, il faut la calculer avant d'appeler ces fonctions .
+    !
+    !   ----------------------------------------------------------------
+    ! Fonctions a changer eventuellement, selon x(x) et y(y) choisis .
+    !   -----------------------------------------------------------------
+    !
+    !    .....  ici, on a l'application particuliere suivante   ........
+    !
+    !            **************************************
+    !            **     x = 2. * pi/iim *  X         **
+    !            **     y =      pi/jjm *  Y         **
+    !            **************************************
+    !
+    !   ..................................................................
+    !   ..................................................................
+    !
+    !
+    !
+    !-----------------------------------------------------------------------
+  END SUBROUTINE fxy_sin
+
+  SUBROUTINE fxy_prim(fy, fx, fxprim, fyprim, ri, rj)
+    REAL :: fy, fx, fxprim, fyprim, ri, rj
+
+    fy    (rj) = pi / REAL(jjm) * (0.5 * REAL(jjm) + 1. - rj)
+    fyprim(rj) = pi / REAL(jjm)
+
+    ! fy(rj)=ASIN(1.+2.*((1.-rj)/REAL(jjm)))
+    ! fyprim(rj)=1./SQRT((rj-1.)*(jjm+1.-rj))
+
+    fx    (ri) = 2. * pi / REAL(iim) * (ri - 0.5 * REAL(iim) - 1.)
+    ! fx    ( ri ) = 2.*pi/REAL(iim) * ( ri - 0.5* ( REAL(iim) + 1.) )
+    fxprim(ri) = 2. * pi / REAL(iim)
+    !
+    !
+    !    La valeur de pi est passee par le common/const/ou /const2/ .
+    !    Sinon, il faut la calculer avant d'appeler ces fonctions .
+    !
+    !   ----------------------------------------------------------------
+    ! Fonctions a changer eventuellement, selon x(x) et y(y) choisis .
+    !   -----------------------------------------------------------------
+    !
+    !    .....  ici, on a l'application particuliere suivante   ........
+    !
+    !            **************************************
+    !            **     x = 2. * pi/iim *  X         **
+    !            **     y =      pi/jjm *  Y         **
+    !            **************************************
+    !
+    !   ..................................................................
+    !   ..................................................................
+    !
+    !
+    !
+    !-----------------------------------------------------------------------
+  END SUBROUTINE fxy_prim
+END MODULE lmdz_fxy
